From 90b6745bc80cf6dabb8f736dbf12d47c2a6602f5 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 7 Aug 2020 22:26:07 -0500 Subject: [PATCH] intel/fs,vec4: Stuff the constant data from NIR in the end of the program Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw_compiler.h | 3 +++ src/intel/compiler/brw_fs.cpp | 4 ++++ src/intel/compiler/brw_fs.h | 1 + src/intel/compiler/brw_fs_generator.cpp | 10 ++++++++++ src/intel/compiler/brw_shader.cpp | 2 ++ src/intel/compiler/brw_vec4.cpp | 1 + src/intel/compiler/brw_vec4_generator.cpp | 7 +++++++ src/intel/compiler/brw_vec4_gs_visitor.cpp | 1 + src/intel/compiler/brw_vec4_tcs.cpp | 2 ++ 9 files changed, 31 insertions(+) diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h index 8df2ee59207..679a78723fe 100644 --- a/src/intel/compiler/brw_compiler.h +++ b/src/intel/compiler/brw_compiler.h @@ -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; diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 388fd8dec28..460a36587a1 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -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; diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h index c24438a737e..0843f6e73fc 100644 --- a/src/intel/compiler/brw_fs.h +++ b/src/intel/compiler/brw_fs.h @@ -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: diff --git a/src/intel/compiler/brw_fs_generator.cpp b/src/intel/compiler/brw_fs_generator.cpp index df357440d49..74c6cd30474 100644 --- a/src/intel/compiler/brw_fs_generator.cpp +++ b/src/intel/compiler/brw_fs_generator.cpp @@ -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() { diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index e78f2cbe50a..3219a01e60a 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -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, diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp index 864ece7e636..fe7db43066d 100644 --- a/src/intel/compiler/brw_vec4.cpp +++ b/src/intel/compiler/brw_vec4.cpp @@ -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(); } diff --git a/src/intel/compiler/brw_vec4_generator.cpp b/src/intel/compiler/brw_vec4_generator.cpp index 43fcdf70ff0..e9142c2c65c 100644 --- a/src/intel/compiler/brw_vec4_generator.cpp +++ b/src/intel/compiler/brw_vec4_generator.cpp @@ -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); } diff --git a/src/intel/compiler/brw_vec4_gs_visitor.cpp b/src/intel/compiler/brw_vec4_gs_visitor.cpp index 58f6f1212ac..b286bfd9645 100644 --- a/src/intel/compiler/brw_vec4_gs_visitor.cpp +++ b/src/intel/compiler/brw_vec4_gs_visitor.cpp @@ -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(); } } diff --git a/src/intel/compiler/brw_vec4_tcs.cpp b/src/intel/compiler/brw_vec4_tcs.cpp index e9a6880cfbe..29c0d9e63d7 100644 --- a/src/intel/compiler/brw_vec4_tcs.cpp +++ b/src/intel/compiler/brw_vec4_tcs.cpp @@ -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, -- 2.30.2