diff options
Diffstat (limited to 'common/recipes-graphics/mesa')
16 files changed, 0 insertions, 3239 deletions
diff --git a/common/recipes-graphics/mesa/mesa/0001-configure.ac-adjust-usage-of-LLVM-flags.patch b/common/recipes-graphics/mesa/mesa/0001-configure.ac-adjust-usage-of-LLVM-flags.patch deleted file mode 100644 index a6599648..00000000 --- a/common/recipes-graphics/mesa/mesa/0001-configure.ac-adjust-usage-of-LLVM-flags.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 223ffdb659ceb8628e38003495b5c6550833b673 Mon Sep 17 00:00:00 2001 -From: Awais Belal <awais_belal@mentor.com> -Date: Thu, 26 Jul 2018 17:13:32 +0500 -Subject: [PATCH] configure.ac: adjust usage of LLVM flags - -The llvm-config is provided through a native build -so using flags from there creates conflicts between -mesa and llvm on the target. - -Signed-off-by: Awais Belal <awais_belal@mentor.com> ---- - configure.ac | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index d1c8bb82da..290cc5f9f8 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1064,6 +1064,7 @@ strip_unwanted_llvm_flags() { - -e 's/[[[:space:]]]+-pedantic[[[:space:]]]/ /g' \ - -e 's/[[[:space:]]]+-W[[^[:space:]]]*//g' \ - -e 's/[[[:space:]]]+-O[[^[:space:]]]*//g' \ -+ -e 's/[[[:space:]]]+-D_GLIBCXX_USE_CXX11_ABI[[^[:space:]]]*//g' \ - -e 's/[[[:space:]]]+-g[[^[:space:]]]*//g' \ - -e 's/-fno-rtti[[[:space:]]]/-Fno-rtti /g' \ - -e 's/[[[:space:]]]+-f[[^[:space:]]]*//g' \ -@@ -2808,7 +2809,7 @@ dnl - if test "x$enable_llvm" = xyes; then - DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT -DMESA_LLVM_VERSION_PATCH=$LLVM_VERSION_PATCH" - -- LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags` -+ LLVM_LDFLAGS= - LLVM_CFLAGS=$LLVM_CPPFLAGS # CPPFLAGS seem to be sufficient - LLVM_CXXFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cxxflags"` - --- -2.11.1 diff --git a/common/recipes-graphics/mesa/mesa/0001-configure.ac-obey-llvm_prefix-if-available.patch b/common/recipes-graphics/mesa/mesa/0001-configure.ac-obey-llvm_prefix-if-available.patch deleted file mode 100644 index 76e152e7..00000000 --- a/common/recipes-graphics/mesa/mesa/0001-configure.ac-obey-llvm_prefix-if-available.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 8dc29db401030725ca0201ba03feb6238ec258f7 Mon Sep 17 00:00:00 2001 -From: Awais Belal <awais_belal@mentor.com> -Date: Fri, 20 Jul 2018 17:58:45 +0500 -Subject: [PATCH] configure.ac: obey llvm_prefix if available - -Signed-off-by: Awais Belal <awais_belal@mentor.com> ---- - configure.ac | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index d1c8bb82da..92a83fec4a 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -2821,7 +2821,11 @@ if test "x$enable_llvm" = xyes; then - - if test $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 9; then - if test "x$enable_llvm_shared_libs" = xyes; then -- LLVM_LIBS="`$LLVM_CONFIG --link-shared --libs ${LLVM_COMPONENTS}`" -+ if test "x${llvm_prefix}" == "x"; then -+ LLVM_LIBS="`$LLVM_CONFIG --link-shared --libs ${LLVM_COMPONENTS}`" -+ else -+ LLVM_LIBS="`$LLVM_CONFIG --link-shared --libs ${LLVM_COMPONENTS} --tgtlibdir ${llvm_prefix}`" -+ fi - else - dnl Invoking llvm-config with both -libs and --system-libs produces the - dnl two separate lines - each for the set of libraries. --- -2.11.1 - diff --git a/common/recipes-graphics/mesa/mesa/0001-st-omx-enc-fix-blit-setup-for-YUV-LoadImage.patch b/common/recipes-graphics/mesa/mesa/0001-st-omx-enc-fix-blit-setup-for-YUV-LoadImage.patch deleted file mode 100644 index edfe3678..00000000 --- a/common/recipes-graphics/mesa/mesa/0001-st-omx-enc-fix-blit-setup-for-YUV-LoadImage.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 62bf8198ff125f9e04457bd18ec2c1f7b2ba4cdf Mon Sep 17 00:00:00 2001 -From: Leo Liu <leo.liu@amd.com> -Date: Fri, 27 Apr 2018 08:32:41 -0400 -Subject: [PATCH 01/13] st/omx/enc: fix blit setup for YUV LoadImage -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -The blit here involves scaling since it's copying from I8 format to R8G8 format. -Half of source will be filtered out with PIPE_TEX_FILTER_NEAREST instruction, it -looks that GPU always uses the second half as source. Currently we use "1" as -the start point of x for R, then causing 1 source pixel of U component shift to -right. So "-1" should be the start point for U component. - -Cc: 18.0 18.1 <mesa-stable@lists.freedesktop.org> -Reviewed-by: Marek Olšák <marek.olsak@amd.com> ---- - src/gallium/state_trackers/omx/vid_enc_common.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/src/gallium/state_trackers/omx/vid_enc_common.c b/src/gallium/state_trackers/omx/vid_enc_common.c -index 874dd3a..2aa739d 100644 ---- a/src/gallium/state_trackers/omx/vid_enc_common.c -+++ b/src/gallium/state_trackers/omx/vid_enc_common.c -@@ -353,7 +353,7 @@ OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEF - blit.src.resource = inp->resource; - blit.src.format = inp->resource->format; - -- blit.src.box.x = 0; -+ blit.src.box.x = -1; - blit.src.box.y = def->nFrameHeight; - blit.src.box.width = def->nFrameWidth; - blit.src.box.height = def->nFrameHeight / 2 ; -@@ -367,11 +367,11 @@ OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEF - blit.dst.box.depth = 1; - blit.filter = PIPE_TEX_FILTER_NEAREST; - -- blit.mask = PIPE_MASK_G; -+ blit.mask = PIPE_MASK_R; - priv->s_pipe->blit(priv->s_pipe, &blit); - -- blit.src.box.x = 1; -- blit.mask = PIPE_MASK_R; -+ blit.src.box.x = 0; -+ blit.mask = PIPE_MASK_G; - priv->s_pipe->blit(priv->s_pipe, &blit); - priv->s_pipe->flush(priv->s_pipe, NULL, 0); - --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0002-mesa-st-glsl_to_tgsi-Split-arrays-who-s-elements-are.patch b/common/recipes-graphics/mesa/mesa/0002-mesa-st-glsl_to_tgsi-Split-arrays-who-s-elements-are.patch deleted file mode 100644 index 6ee5cbdd..00000000 --- a/common/recipes-graphics/mesa/mesa/0002-mesa-st-glsl_to_tgsi-Split-arrays-who-s-elements-are.patch +++ /dev/null @@ -1,165 +0,0 @@ -From d29d4b81188e50010058f9c409936713e84bf67d Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:06 +0100 -Subject: [PATCH 02/13] mesa/st: glsl_to_tgsi: Split arrays who's elements are - only accessed directly - -Array who's elements are only accessed directly are replaced by the -according number of temporary registers. By doing so the otherwise -reserved register range becomes subject to further optimizations like -copy propagation and register merging. - -Thanks to the resulting reduced register pressure this patch makes -the piglits - - spec/glsl-1.50/execution - - variable-indexing/vs-output-array-vec3-index-wr-before-gs - geometry/max-input-components - -pass on r600 (barts) where they would fail before with a "GPR limit exceeded" -error. - -v2: * rename method dissolve_arrays to split_arrays - * unify the tracking and remapping methods for src and st registers - * also track access to arrays via reladdr* - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 107 +++++++++++++++++++++++++++++ - 1 file changed, 107 insertions(+) - -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp -index 911c855..7413874 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp -@@ -337,6 +337,7 @@ public: - void copy_propagate(void); - int eliminate_dead_code(void); - -+ void split_arrays(void); - void merge_two_dsts(void); - void merge_registers(void); - void renumber_registers(void); -@@ -5362,6 +5363,110 @@ glsl_to_tgsi_visitor::merge_two_dsts(void) - } - } - -+ -+ -+/* One-dimensional arrays who's elements are only accessed directly are -+ * replaced by an according set of temporary registers that then can become -+ * subject to further optimization steps like copy propagation and -+ * register merging. -+ */ -+ -+template <typename st_reg> -+void test_indirect_access(const st_reg& reg, bool *has_indirect_access) -+{ -+ if (reg.file == PROGRAM_ARRAY) { -+ if (reg.reladdr || reg.reladdr2 || reg.has_index2) { -+ has_indirect_access[reg.array_id] = true; -+ if (reg.reladdr) -+ test_indirect_access(*reg.reladdr, has_indirect_access); -+ if (reg.reladdr2) -+ test_indirect_access(*reg.reladdr, has_indirect_access); -+ } -+ } -+} -+ -+template <typename st_reg> -+void remap_array(st_reg& reg, const int *array_remap_info, -+ const bool *has_indirect_access) -+{ -+ if (reg.file == PROGRAM_ARRAY) { -+ if (!has_indirect_access[reg.array_id]) { -+ reg.file = PROGRAM_TEMPORARY; -+ reg.index = reg.index + array_remap_info[reg.array_id]; -+ reg.array_id = 0; -+ } else { -+ reg.array_id = array_remap_info[reg.array_id]; -+ } -+ -+ if (reg.reladdr) -+ remap_array(*reg.reladdr, array_remap_info, has_indirect_access); -+ -+ if (reg.reladdr2) -+ remap_array(*reg.reladdr2, array_remap_info, has_indirect_access); -+ } -+} -+ -+void -+glsl_to_tgsi_visitor::split_arrays(void) -+{ -+ if (!next_array) -+ return; -+ -+ bool *has_indirect_access = rzalloc_array(mem_ctx, bool, next_array + 1); -+ -+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) { -+ for (unsigned j = 0; j < num_inst_src_regs(inst); j++) -+ test_indirect_access(inst->src[j], has_indirect_access); -+ -+ for (unsigned j = 0; j < inst->tex_offset_num_offset; j++) -+ test_indirect_access(inst->tex_offsets[j], has_indirect_access); -+ -+ for (unsigned j = 0; j < num_inst_dst_regs(inst); j++) -+ test_indirect_access(inst->dst[j], has_indirect_access); -+ } -+ -+ unsigned array_offset = 0; -+ unsigned n_remaining_arrays = 0; -+ -+ /* Double use: For arrays that get split this value will contain -+ * the base index of the temporary registers this array is replaced -+ * with. For arrays that remain it contains the new array ID. -+ */ -+ int *array_remap_info = rzalloc_array(has_indirect_access, int, -+ next_array + 1); -+ -+ for (unsigned i = 1; i <= next_array; ++i) { -+ if (!has_indirect_access[i]) { -+ array_remap_info[i] = this->next_temp + array_offset; -+ array_offset += array_sizes[i-1]; -+ } else { -+ array_sizes[n_remaining_arrays] = array_sizes[i-1]; -+ array_remap_info[i] = ++n_remaining_arrays; -+ } -+ } -+ -+ if (next_array != n_remaining_arrays) { -+ -+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) { -+ -+ for (unsigned j = 0; j < num_inst_src_regs(inst); j++) -+ remap_array(inst->src[j], array_remap_info, has_indirect_access); -+ -+ for (unsigned j = 0; j < inst->tex_offset_num_offset; j++) -+ remap_array(inst->tex_offsets[j], array_remap_info, has_indirect_access); -+ -+ for (unsigned j = 0; j < num_inst_dst_regs(inst); j++) { -+ remap_array(inst->dst[j], array_remap_info, has_indirect_access); -+ } -+ } -+ } -+ -+ ralloc_free(has_indirect_access); -+ -+ this->next_temp += array_offset; -+ next_array = n_remaining_arrays; -+} -+ - /* Merges temporary registers together where possible to reduce the number of - * registers needed to run a program. - * -@@ -6823,6 +6928,8 @@ get_mesa_program_tgsi(struct gl_context *ctx, - } - #endif - -+ v->split_arrays(); -+ - /* Perform optimizations on the instructions in the glsl_to_tgsi_visitor. */ - v->simplify_cmp(); - v->copy_propagate(); --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0003-mesa-st-glsl_to_tgsi-rename-lifetime-to-register_liv.patch b/common/recipes-graphics/mesa/mesa/0003-mesa-st-glsl_to_tgsi-rename-lifetime-to-register_liv.patch deleted file mode 100644 index 774e7f09..00000000 --- a/common/recipes-graphics/mesa/mesa/0003-mesa-st-glsl_to_tgsi-rename-lifetime-to-register_liv.patch +++ /dev/null @@ -1,522 +0,0 @@ -From 73193fae57d2b9ab6dae144fc966c47f86a3206f Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:07 +0100 -Subject: [PATCH 03/13] mesa/st/glsl_to_tgsi: rename lifetime to - register_live_range - -On one hand "live range" is the term used in the literature, and on the -other hand a distinction is needed from the array live ranges that will -be introduced later. - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 16 ++--- - .../state_tracker/st_glsl_to_tgsi_temprename.cpp | 78 +++++++++++----------- - .../state_tracker/st_glsl_to_tgsi_temprename.h | 36 +++++----- - src/mesa/state_tracker/tests/st_tests_common.cpp | 16 +++-- - src/mesa/state_tracker/tests/st_tests_common.h | 13 ++-- - .../tests/test_glsl_to_tgsi_lifetime.cpp | 10 +-- - 6 files changed, 88 insertions(+), 81 deletions(-) - -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp -index 7413874..163f334 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp -@@ -5475,19 +5475,19 @@ glsl_to_tgsi_visitor::split_arrays(void) - void - glsl_to_tgsi_visitor::merge_registers(void) - { -- struct lifetime *lifetimes = -- rzalloc_array(mem_ctx, struct lifetime, this->next_temp); -+ struct register_live_range *reg_live_ranges = -+ rzalloc_array(mem_ctx, struct register_live_range, this->next_temp); - -- if (get_temp_registers_required_lifetimes(mem_ctx, &this->instructions, -- this->next_temp, lifetimes)) { -+ if (get_temp_registers_required_live_ranges(reg_live_ranges, &this->instructions, -+ this->next_temp, reg_live_ranges)) { - struct rename_reg_pair *renames = -- rzalloc_array(mem_ctx, struct rename_reg_pair, this->next_temp); -- get_temp_registers_remapping(mem_ctx, this->next_temp, lifetimes, renames); -+ rzalloc_array(reg_live_ranges, struct rename_reg_pair, this->next_temp); -+ get_temp_registers_remapping(reg_live_ranges, this->next_temp, -+ reg_live_ranges, renames); - rename_temp_registers(renames); - ralloc_free(renames); - } -- -- ralloc_free(lifetimes); -+ ralloc_free(reg_live_ranges); - } - - /* Reassign indices to temporary registers by reusing unused indices created -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -index 6921a64..73f52cf 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -@@ -154,9 +154,9 @@ public: - - void record_read(int line, prog_scope *scope); - void record_write(int line, prog_scope *scope); -- lifetime get_required_lifetime(); -+ register_live_range get_required_live_range(); - private: -- void propagate_lifetime_to_dominant_write_scope(); -+ void propagate_live_range_to_dominant_write_scope(); - bool conditional_ifelse_write_in_loop() const; - - void record_ifelse_write(const prog_scope& scope); -@@ -230,7 +230,7 @@ public: - temp_access(); - void record_read(int line, prog_scope *scope, int swizzle); - void record_write(int line, prog_scope *scope, int writemask); -- lifetime get_required_lifetime(); -+ register_live_range get_required_live_range(); - private: - void update_access_mask(int mask); - -@@ -513,22 +513,22 @@ void temp_access::record_read(int line, prog_scope *scope, int swizzle) - comp[3].record_read(line, scope); - } - --inline static lifetime make_lifetime(int b, int e) -+inline static register_live_range make_live_range(int b, int e) - { -- lifetime lt; -+ register_live_range lt; - lt.begin = b; - lt.end = e; - return lt; - } - --lifetime temp_access::get_required_lifetime() -+register_live_range temp_access::get_required_live_range() - { -- lifetime result = make_lifetime(-1, -1); -+ register_live_range result = make_live_range(-1, -1); - - unsigned mask = access_mask; - while (mask) { - unsigned chan = u_bit_scan(&mask); -- lifetime lt = comp[chan].get_required_lifetime(); -+ register_live_range lt = comp[chan].get_required_live_range(); - - if (lt.begin >= 0) { - if ((result.begin < 0) || (result.begin > lt.begin)) -@@ -766,7 +766,7 @@ bool temp_comp_access::conditional_ifelse_write_in_loop() const - return conditionality_in_loop_id <= conditionality_unresolved; - } - --void temp_comp_access::propagate_lifetime_to_dominant_write_scope() -+void temp_comp_access::propagate_live_range_to_dominant_write_scope() - { - first_write = first_write_scope->begin(); - int lr = first_write_scope->end(); -@@ -775,7 +775,7 @@ void temp_comp_access::propagate_lifetime_to_dominant_write_scope() - last_read = lr; - } - --lifetime temp_comp_access::get_required_lifetime() -+register_live_range temp_comp_access::get_required_live_range() - { - bool keep_for_full_loop = false; - -@@ -785,7 +785,7 @@ lifetime temp_comp_access::get_required_lifetime() - * eliminating registers that are not written to. - */ - if (last_write < 0) -- return make_lifetime(-1, -1); -+ return make_live_range(-1, -1); - - assert(first_write_scope); - -@@ -793,7 +793,7 @@ lifetime temp_comp_access::get_required_lifetime() - * reused in the range it is used to write to - */ - if (!last_read_scope) -- return make_lifetime(first_write, last_write + 1); -+ return make_live_range(first_write, last_write + 1); - - const prog_scope *enclosing_scope_first_read = first_read_scope; - const prog_scope *enclosing_scope_first_write = first_write_scope; -@@ -837,7 +837,7 @@ lifetime temp_comp_access::get_required_lifetime() - /* Propagate the last read scope to the target scope */ - while (enclosing_scope->nesting_depth() < last_read_scope->nesting_depth()) { - /* If the read is in a loop and we have to move up the scope we need to -- * extend the life time to the end of this current loop because at this -+ * extend the live range to the end of this current loop because at this - * point we don't know whether the component was written before - * un-conditionally in the same loop. - */ -@@ -848,42 +848,42 @@ lifetime temp_comp_access::get_required_lifetime() - } - - /* If the variable has to be kept for the whole loop, and we -- * are currently in a loop, then propagate the life time. -+ * are currently in a loop, then propagate the live range. - */ - if (keep_for_full_loop && first_write_scope->is_loop()) -- propagate_lifetime_to_dominant_write_scope(); -+ propagate_live_range_to_dominant_write_scope(); - - /* Propagate the first_dominant_write scope to the target scope */ - while (enclosing_scope->nesting_depth() < first_write_scope->nesting_depth()) { -- /* Propagate lifetime if there was a break in a loop and the write was -+ /* Propagate live_range if there was a break in a loop and the write was - * after the break inside that loop. Note, that this is only needed if - * we move up in the scopes. - */ - if (first_write_scope->loop_break_line() < first_write) { - keep_for_full_loop = true; -- propagate_lifetime_to_dominant_write_scope(); -+ propagate_live_range_to_dominant_write_scope(); - } - - first_write_scope = first_write_scope->parent(); - -- /* Propagte lifetime if we are now in a loop */ -+ /* Propagte live_range if we are now in a loop */ - if (keep_for_full_loop && first_write_scope->is_loop()) -- propagate_lifetime_to_dominant_write_scope(); -+ propagate_live_range_to_dominant_write_scope(); - } - - /* The last write past the last read is dead code, but we have to - * ensure that the component is not reused too early, hence extend the -- * lifetime past the last write. -+ * live_range past the last write. - */ - if (last_write >= last_read) - last_read = last_write + 1; - - /* Here we are at the same scope, all is resolved */ -- return make_lifetime(first_write, last_read); -+ return make_live_range(first_write, last_read); - } - - /* Helper class for sorting and searching the registers based -- * on life times. */ -+ * on live ranges. */ - class access_record { - public: - int begin; -@@ -904,7 +904,7 @@ public: - void record_read(const st_src_reg& src, int line, prog_scope *scope); - void record_write(const st_dst_reg& src, int line, prog_scope *scope); - -- void get_required_lifetimes(struct lifetime *lifetimes); -+ void get_required_live_ranges(register_live_range *live_ranges); - private: - - int ntemps; -@@ -947,14 +947,14 @@ void access_recorder::record_write(const st_dst_reg& dst, int line, - record_read(*dst.reladdr2, line, scope); - } - --void access_recorder::get_required_lifetimes(struct lifetime *lifetimes) -+void access_recorder::get_required_live_ranges(struct register_live_range *live_ranges) - { -- RENAME_DEBUG(debug_log << "========= lifetimes ==============\n"); -+ RENAME_DEBUG(debug_log << "=========live_ranges ==============\n"); - for(int i = 0; i < ntemps; ++i) { - RENAME_DEBUG(debug_log<< setw(4) << i); -- lifetimes[i] = acc[i].get_required_lifetime(); -- RENAME_DEBUG(debug_log << ": [" << lifetimes[i].begin << ", " -- << lifetimes[i].end << "]\n"); -+ live_ranges[i] = acc[i].get_required_live_range(); -+ RENAME_DEBUG(debug_log << ": [" <<live_ranges[i].begin << ", " -+ <<live_ranges[i].end << "]\n"); - } - RENAME_DEBUG(debug_log << "==================================\n\n"); - } -@@ -967,12 +967,12 @@ static void dump_instruction(ostream& os, int line, prog_scope *scope, - const glsl_to_tgsi_instruction& inst); - #endif - --/* Scan the program and estimate the required register life times. -- * The array lifetimes must be pre-allocated -+/* Scan the program and estimate the required register live ranges. -+ * live_ranges must be pre-allocated. - */ - bool --get_temp_registers_required_lifetimes(void *mem_ctx, exec_list *instructions, -- int ntemps, struct lifetime *lifetimes) -+get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, -+ int ntemps, struct register_live_range *live_ranges) - { - int line = 0; - int loop_id = 1; -@@ -1110,7 +1110,7 @@ get_temp_registers_required_lifetimes(void *mem_ctx, exec_list *instructions, - case TGSI_OPCODE_CAL: - case TGSI_OPCODE_RET: - /* These opcodes are not supported and if a subroutine would -- * be called in a shader, then the lifetime tracking would have -+ * be called in a shader, then the live_range tracking would have - * to follow that call to see which registers are used there. - * Since this is not done, we have to bail out here and signal - * that no register merge will take place. -@@ -1139,11 +1139,11 @@ get_temp_registers_required_lifetimes(void *mem_ctx, exec_list *instructions, - if (cur_scope->end() < 0) - cur_scope->set_end(line - 1); - -- access.get_required_lifetimes(lifetimes); -+ access.get_required_live_ranges(live_ranges); - return true; - } - --/* Find the next register between [start, end) that has a life time starting -+/* Find the next register between [start, end) that has a live range starting - * at or after bound by using a binary search. - * start points at the beginning of the search range, - * end points at the element past the end of the search range, and -@@ -1181,16 +1181,16 @@ static int access_record_compare (const void *a, const void *b) { - /* This functions evaluates the register merges by using a binary - * search to find suitable merge candidates. */ - void get_temp_registers_remapping(void *mem_ctx, int ntemps, -- const struct lifetime* lifetimes, -+ const struct register_live_range *live_ranges, - struct rename_reg_pair *result) - { - access_record *reg_access = ralloc_array(mem_ctx, access_record, ntemps); - - int used_temps = 0; - for (int i = 0; i < ntemps; ++i) { -- if (lifetimes[i].begin >= 0) { -- reg_access[used_temps].begin = lifetimes[i].begin; -- reg_access[used_temps].end = lifetimes[i].end; -+ if (live_ranges[i].begin >= 0) { -+ reg_access[used_temps].begin =live_ranges[i].begin; -+ reg_access[used_temps].end =live_ranges[i].end; - reg_access[used_temps].reg = i; - reg_access[used_temps].erase = false; - ++used_temps; -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h -index 3f21b13..375d5b8 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h -@@ -26,46 +26,48 @@ - - #include "st_glsl_to_tgsi_private.h" - --/** Storage to record the required life time of a temporary register -+/** Storage to record the required live range of a temporary register - * begin == end == -1 indicates that the register can be reused without - * limitations. Otherwise, "begin" indicates the first instruction in which - * a write operation may target this temporary, and end indicates the - * last instruction in which a value can be read from this temporary. - * Hence, a register R2 can be merged with a register R1 if R1.end <= R2.begin. - */ --struct lifetime { -+struct register_live_range { - int begin; - int end; - }; - --/** Evaluates the required life times of temporary registers in a shader. -- * The life time estimation can only be run sucessfully if the shader doesn't -+/** Evaluates the required live ranges of temporary registers in a shader. -+ * The live range estimation can only be run sucessfully if the shader doesn't - * call a subroutine. -- * @param[in] mem_ctx a memory context that can be used with the ralloc_* functions -+ * @param[in] mem_ctx a memory context that can be used with the ralloc_* -+ * functions - * @param[in] instructions the shader to be anlzyed - * @param[in] ntemps number of temporaries reserved for this shader -- * @param[in,out] lifetimes memory location to store the estimated required -- * life times for each temporary register. The parameter must point to -- * allocated memory that can hold ntemps lifetime structures. On output -- * the life times contains the life times for the registers with the -- * exception of TEMP[0]. -+ * @param[in,out] reg_live_ranges memory location to store the estimated -+ * required live ranges for each temporary register. The parameter must -+ * point to allocated memory that can hold ntemps register_live_range -+ * structures. On output the live ranges contains the live ranges for -+ * the registers with the exception of TEMP[0] - * @returns: true if the lifetimes were estimated, false if not (i.e. if a - * subroutine was called). - */ - bool --get_temp_registers_required_lifetimes(void *mem_ctx, exec_list *instructions, -- int ntemps, struct lifetime *lifetimes); -+get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, -+ int ntemps, struct register_live_range *live_ranges); -+ - /** Estimate the merge remapping of the registers. -- * @param[in] mem_ctx a memory context that can be used with the ralloc_* functions -+ * @param[in] mem_ctx a memory context that can be used with the ralloc_* -+ * functions - * @param[in] ntemps number of temporaries reserved for this shader -- * @param[in] lifetimes required life time for each temporary register. -+ * @param[in] reg_live_ranges required live range for each temporary register. - * @param[in,out] result memory location to store the register remapping table. - * On input the parameter must point to allocated memory that can hold the - * renaming information for ntemps registers, on output the mapping is stored. - * Note that TEMP[0] is not considered for register renaming. - */ - void get_temp_registers_remapping(void *mem_ctx, int ntemps, -- const struct lifetime* lifetimes, -- struct rename_reg_pair *result); -- -+ const struct register_live_range* reg_live_ranges, -+ struct rename_reg_pair *result); - #endif -\ No newline at end of file -diff --git a/src/mesa/state_tracker/tests/st_tests_common.cpp b/src/mesa/state_tracker/tests/st_tests_common.cpp -index ea01ca5..f1e4a83 100644 ---- a/src/mesa/state_tracker/tests/st_tests_common.cpp -+++ b/src/mesa/state_tracker/tests/st_tests_common.cpp -@@ -411,7 +411,7 @@ LifetimeEvaluatorTest::run(const vector<FakeCodeline>& code, bool& success) - lifetime_result result(shader.get_num_temps()); - - success = -- get_temp_registers_required_lifetimes(mem_ctx, shader.get_program(mem_ctx), -+ get_temp_registers_required_live_ranges(mem_ctx, shader.get_program(mem_ctx), - shader.get_num_temps(), - &result[0]); - -@@ -422,8 +422,9 @@ void LifetimeEvaluatorTest::run(const vector<FakeCodeline>& code, const temp_lt_ - { - FakeShader shader(code); - lifetime_result result(shader.get_num_temps()); -+ - bool success = -- get_temp_registers_required_lifetimes(mem_ctx, shader.get_program(mem_ctx), -+ get_temp_registers_required_live_ranges(mem_ctx, shader.get_program(mem_ctx), - shader.get_num_temps(), - &result[0]); - ASSERT_TRUE(success); -@@ -431,7 +432,7 @@ void LifetimeEvaluatorTest::run(const vector<FakeCodeline>& code, const temp_lt_ - check(result, e); - } - --void LifetimeEvaluatorExactTest::check( const vector<lifetime>& lifetimes, -+void LifetimeEvaluatorExactTest::check( const vector<register_live_range>& lifetimes, - const temp_lt_expect& e) - { - for (unsigned i = 1; i < lifetimes.size(); ++i) { -@@ -440,7 +441,7 @@ void LifetimeEvaluatorExactTest::check( const vector<lifetime>& lifetimes, - } - } - --void LifetimeEvaluatorAtLeastTest::check( const vector<lifetime>& lifetimes, -+void LifetimeEvaluatorAtLeastTest::check( const vector<register_live_range>& lifetimes, - const temp_lt_expect& e) - { - for (unsigned i = 1; i < lifetimes.size(); ++i) { -@@ -449,7 +450,7 @@ void LifetimeEvaluatorAtLeastTest::check( const vector<lifetime>& lifetimes, - } - } - --void RegisterRemappingTest::run(const vector<lifetime>& lt, -+void RegisterRemappingTest::run(const vector<register_live_range>& lt, - const vector<int>& expect) - { - rename_reg_pair proto{false,0}; -@@ -476,8 +477,9 @@ void RegisterLifetimeAndRemappingTest::run(const vector<FakeCodeline>& code, - const vector<int>& expect) - { - FakeShader shader(code); -- std::vector<lifetime> lt(shader.get_num_temps()); -- get_temp_registers_required_lifetimes(mem_ctx, shader.get_program(mem_ctx), -+ std::vector<register_live_range> lt(shader.get_num_temps()); -+ -+ get_temp_registers_required_live_ranges(mem_ctx, shader.get_program(mem_ctx), - shader.get_num_temps(), <[0]); - this->run(lt, expect); - } -diff --git a/src/mesa/state_tracker/tests/st_tests_common.h b/src/mesa/state_tracker/tests/st_tests_common.h -index 2e18832..0fcec62 100644 ---- a/src/mesa/state_tracker/tests/st_tests_common.h -+++ b/src/mesa/state_tracker/tests/st_tests_common.h -@@ -131,17 +131,19 @@ class LifetimeEvaluatorTest : public MesaTestWithMemCtx { - protected: - void run(const std::vector<FakeCodeline>& code, const temp_lt_expect& e); - private: -- using lifetime_result=std::vector<lifetime>; -+ using lifetime_result=std::vector<register_live_range>; - lifetime_result run(const std::vector<FakeCodeline>& code, bool& success); - -- virtual void check(const std::vector<lifetime>& result, const temp_lt_expect& e) = 0; -+ virtual void check(const std::vector<register_live_range>& result, -+ const temp_lt_expect& e) = 0; - }; - - /* This is a test class to check the exact life times of - * registers. */ - class LifetimeEvaluatorExactTest : public LifetimeEvaluatorTest { - protected: -- void check(const std::vector<lifetime>& result, const temp_lt_expect& e); -+ void check(const std::vector<register_live_range>& result, -+ const temp_lt_expect& e); - - }; - -@@ -152,13 +154,14 @@ protected: - */ - class LifetimeEvaluatorAtLeastTest : public LifetimeEvaluatorTest { - protected: -- void check(const std::vector<lifetime>& result, const temp_lt_expect& e); -+ void check(const std::vector<register_live_range>& result, const temp_lt_expect& e); - }; - - /* With this test class the renaming mapping estimation is tested */ - class RegisterRemappingTest : public MesaTestWithMemCtx { - protected: -- void run(const std::vector<lifetime>& lt, const std::vector<int> &expect); -+ void run(const std::vector<register_live_range>& lt, -+ const std::vector<int> &expect); - }; - - /* With this test class the combined lifetime estimation and renaming -diff --git a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp -index acebfb8..dbf74cc 100644 ---- a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp -+++ b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp -@@ -1684,7 +1684,7 @@ TEST_F(LifetimeEvaluatorExactTest, WriteIndirectReladdr2) - */ - TEST_F(RegisterRemappingTest, RegisterRemapping1) - { -- vector<lifetime> lt({{-1,-1}, -+ vector<register_live_range> lt({{-1,-1}, - {0,1}, - {0,2}, - {1,2}, -@@ -1699,7 +1699,7 @@ TEST_F(RegisterRemappingTest, RegisterRemapping1) - - TEST_F(RegisterRemappingTest, RegisterRemapping2) - { -- vector<lifetime> lt({{-1,-1}, -+ vector<register_live_range> lt({{-1,-1}, - {0,1}, - {0,2}, - {3,4}, -@@ -1711,7 +1711,7 @@ TEST_F(RegisterRemappingTest, RegisterRemapping2) - - TEST_F(RegisterRemappingTest, RegisterRemappingMergeAllToOne) - { -- vector<lifetime> lt({{-1,-1}, -+ vector<register_live_range> lt({{-1,-1}, - {0,1}, - {1,2}, - {2,3}, -@@ -1723,7 +1723,7 @@ TEST_F(RegisterRemappingTest, RegisterRemappingMergeAllToOne) - - TEST_F(RegisterRemappingTest, RegisterRemappingIgnoreUnused) - { -- vector<lifetime> lt({{-1,-1}, -+ vector<register_live_range> lt({{-1,-1}, - {0,1}, - {1,2}, - {2,3}, -@@ -1736,7 +1736,7 @@ TEST_F(RegisterRemappingTest, RegisterRemappingIgnoreUnused) - - TEST_F(RegisterRemappingTest, RegisterRemappingMergeZeroLifetimeRegisters) - { -- vector<lifetime> lt({{-1,-1}, -+ vector<register_live_range> lt({{-1,-1}, - {0,1}, - {1,2}, - {2,3}, --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0004-mesa-st-Add-helper-classes-for-array-merging-and-int.patch b/common/recipes-graphics/mesa/mesa/0004-mesa-st-Add-helper-classes-for-array-merging-and-int.patch deleted file mode 100644 index ddb634b6..00000000 --- a/common/recipes-graphics/mesa/mesa/0004-mesa-st-Add-helper-classes-for-array-merging-and-int.patch +++ /dev/null @@ -1,459 +0,0 @@ -From 0397050c39fbb67f954929f8c5c2faeab7b9b08f Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:08 +0100 -Subject: [PATCH 04/13] mesa/st: Add helper classes for array merging and - interleaving - -This class implements the live range merge and component interleave -remapping logic. - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - src/mesa/Makefile.sources | 2 + - src/mesa/meson.build | 2 + - .../state_tracker/st_glsl_to_tgsi_array_merge.cpp | 283 +++++++++++++++++++++ - .../state_tracker/st_glsl_to_tgsi_array_merge.h | 116 +++++++++ - 4 files changed, 403 insertions(+) - create mode 100644 src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp - create mode 100644 src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h - -diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources -index 0a9aad5..789feeb 100644 ---- a/src/mesa/Makefile.sources -+++ b/src/mesa/Makefile.sources -@@ -519,6 +519,8 @@ STATETRACKER_FILES = \ - state_tracker/st_glsl_to_nir.cpp \ - state_tracker/st_glsl_to_tgsi.cpp \ - state_tracker/st_glsl_to_tgsi.h \ -+ state_tracker/st_glsl_to_tgsi_array_merge.cpp \ -+ state_tracker/st_glsl_to_tgsi_array_merge.h \ - state_tracker/st_glsl_to_tgsi_private.cpp \ - state_tracker/st_glsl_to_tgsi_private.h \ - state_tracker/st_glsl_to_tgsi_temprename.cpp \ -diff --git a/src/mesa/meson.build b/src/mesa/meson.build -index aa27d59..2ec5062 100644 ---- a/src/mesa/meson.build -+++ b/src/mesa/meson.build -@@ -566,6 +566,8 @@ files_libmesa_gallium = files( - 'state_tracker/st_glsl_to_nir.cpp', - 'state_tracker/st_glsl_to_tgsi.cpp', - 'state_tracker/st_glsl_to_tgsi.h', -+ 'state_tracker/st_glsl_to_tgsi_array_merge.cpp', -+ 'state_tracker/st_glsl_to_tgsi_array_merge.h', - 'state_tracker/st_glsl_to_tgsi_private.cpp', - 'state_tracker/st_glsl_to_tgsi_private.h', - 'state_tracker/st_glsl_to_tgsi_temprename.cpp', -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp -new file mode 100644 -index 0000000..f432d93 ---- /dev/null -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp -@@ -0,0 +1,283 @@ -+/* -+ * Copyright © 2017 Gert Wollny -+ * -+ * 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. -+ */ -+ -+#include "program/prog_instruction.h" -+#include "util/u_math.h" -+#include <ostream> -+#include <cassert> -+#include <algorithm> -+ -+#include <iostream> -+ -+#include "st_glsl_to_tgsi_array_merge.h" -+ -+#if __cplusplus >= 201402L -+#include <memory> -+using std::unique_ptr; -+using std::make_unique; -+#endif -+ -+namespace tgsi_array_merge { -+ -+array_remapping::array_remapping(): -+ target_id(0), -+ reswizzle(false), -+ finalized(true) -+{ -+} -+ -+array_remapping::array_remapping(int trgt_array_id, unsigned src_access_mask): -+ target_id(trgt_array_id), -+ original_src_access_mask(src_access_mask), -+ reswizzle(false), -+ finalized(false) -+{ -+} -+ -+array_remapping::array_remapping(int trgt_array_id, int trgt_access_mask, -+ int src_access_mask): -+ target_id(trgt_array_id), -+ summary_access_mask(trgt_access_mask), -+ original_src_access_mask(src_access_mask), -+ reswizzle(true), -+ finalized(false) -+{ -+ for (int i = 0; i < 4; ++i) { -+ read_swizzle_map[i] = -1; -+ writemask_map[i] = 0; -+ } -+ -+ int src_swizzle_bit = 1; -+ int next_free_swizzle_bit = 1; -+ int k = 0; -+ bool skip = true; -+ unsigned last_src_bit = util_last_bit(src_access_mask); -+ -+ for (unsigned i = 0; i < 4; ++i, src_swizzle_bit <<= 1) { -+ -+ /* The swizzle mapping fills the unused slots with the last used -+ * component (think temp[A].xyyy) and maps the write mask accordingly. -+ * Hence, if (i < last_src_bit) skip is true and mappings are only added -+ * for used the components, but for (i >= last_src_bit) the mapping -+ * is set for remaining slots. -+ */ -+ if (skip && !(src_swizzle_bit & src_access_mask)) -+ continue; -+ skip = (i < last_src_bit); -+ -+ /* Find the next free access slot in the target.*/ -+ while ((trgt_access_mask & next_free_swizzle_bit) && -+ k < 4) { -+ next_free_swizzle_bit <<= 1; -+ ++k; -+ } -+ assert(k < 4 && -+ "Interleaved array would have more then four components"); -+ -+ /* Set the mapping for this component. */ -+ read_swizzle_map[i] = k; -+ writemask_map[i] = next_free_swizzle_bit; -+ trgt_access_mask |= next_free_swizzle_bit; -+ -+ /* Update the joined access mask if we didn't just fill the mapping.*/ -+ if (src_swizzle_bit & src_access_mask) -+ summary_access_mask |= next_free_swizzle_bit; -+ } -+} -+ -+int array_remapping::map_writemask(int writemask_to_map) const -+{ -+ assert(is_valid()); -+ if (!reswizzle) -+ return writemask_to_map; -+ -+ assert(original_src_access_mask & writemask_to_map); -+ int result = 0; -+ for (int i = 0; i < 4; ++i) { -+ if (1 << i & writemask_to_map) -+ result |= writemask_map[i]; -+ } -+ return result; -+} -+ -+uint16_t array_remapping::move_read_swizzles(uint16_t original_swizzle) const -+{ -+ assert(is_valid()); -+ if (!reswizzle) -+ return original_swizzle; -+ -+ /* Since -+ * -+ * dst.zw = src.xy in glsl actually is MOV dst.__zw src.__xy -+ * -+ * when interleaving the arrays the source swizzles must be moved -+ * according to the changed dst write mask. -+ */ -+ uint16_t out_swizzle = 0; -+ for (int idx = 0; idx < 4; ++idx) { -+ uint16_t orig_swz = GET_SWZ(original_swizzle, idx); -+ int new_idx = read_swizzle_map[idx]; -+ if (new_idx >= 0) -+ out_swizzle |= orig_swz << 3 * new_idx; -+ } -+ return out_swizzle; -+} -+ -+int array_remapping::map_one_swizzle(int swizzle_to_map) const -+{ -+ if (!reswizzle) -+ return swizzle_to_map; -+ -+ assert(read_swizzle_map[swizzle_to_map] >= 0); -+ return read_swizzle_map[swizzle_to_map]; -+} -+ -+uint16_t array_remapping::map_swizzles(uint16_t old_swizzle) const -+{ -+ if (!reswizzle) -+ return old_swizzle; -+ -+ uint16_t out_swizzle = 0; -+ for (int idx = 0; idx < 4; ++idx) { -+ uint16_t swz = map_one_swizzle(GET_SWZ(old_swizzle, idx)); -+ out_swizzle |= swz << 3 * idx; -+ } -+ return out_swizzle; -+} -+ -+void array_remapping::print(std::ostream& os) const -+{ -+ static const char xyzw[] = "xyzw"; -+ if (is_valid()) { -+ os << "[aid: " << target_id; -+ -+ if (reswizzle) { -+ os << " write-swz: "; -+ for (int i = 0; i < 4; ++i) { -+ if (1 << i & original_src_access_mask) { -+ switch (writemask_map[i]) { -+ case 1: os << "x"; break; -+ case 2: os << "y"; break; -+ case 4: os << "z"; break; -+ case 8: os << "w"; break; -+ } -+ } else { -+ os << "_"; -+ } -+ } -+ os << ", read-swz: "; -+ for (int i = 0; i < 4; ++i) { -+ if (1 << i & original_src_access_mask && read_swizzle_map[i] >= 0) -+ os << xyzw[read_swizzle_map[i]]; -+ else -+ os << "_"; -+ } -+ } -+ os << "]"; -+ } else { -+ os << "[unused]"; -+ } -+} -+ -+void array_remapping::finalize_mappings(array_remapping *arr_map) -+{ -+ assert(is_valid()); -+ -+ array_remapping& forward_map = arr_map[target_id]; -+ -+ /* If no valid map is provided than we have a final target array -+ * at the target_id index, no finalization needed. */ -+ if (!forward_map.is_valid()) -+ return; -+ -+ /* This mappoints to another mapped array that may need finalization. */ -+ if (!forward_map.is_finalized()) -+ forward_map.finalize_mappings(arr_map); -+ -+ /* Now finalize this mapping by translating the map to represent -+ * a mapping to a final target array (i.e. one that is not mapped). -+ * This is only necessary if the target_id array map provides reswizzling. -+ */ -+ if (forward_map.reswizzle) { -+ -+ /* If this mapping doesn't have a reswizzle map build one now.*/ -+ if (!reswizzle) { -+ for (int i = 0; i < 4; ++i) { -+ if (1 << i & original_src_access_mask) { -+ read_swizzle_map[i] = i; -+ writemask_map[i] = 1 << i; -+ } else { -+ read_swizzle_map[i] = -1; -+ writemask_map[i] = 0; -+ } -+ } -+ reswizzle = true; -+ } -+ -+ /* Propagate the swizzle mapping of the forward map.*/ -+ for (int i = 0; i < 4; ++i) { -+ if ((1 << i & original_src_access_mask) == 0) -+ continue; -+ read_swizzle_map[i] = forward_map.map_one_swizzle(read_swizzle_map[i]); -+ writemask_map[i] = forward_map.map_writemask(writemask_map[i]); -+ } -+ -+ } -+ -+ /* Now we can skip the intermediate mapping.*/ -+ target_id = forward_map.target_id; -+ finalized = true; -+} -+ -+/* Required by the unit tests */ -+bool operator == (const array_remapping& lhs, const array_remapping& rhs) -+{ -+ if (lhs.target_id != rhs.target_id) -+ return false; -+ -+ if (lhs.target_id == 0) -+ return true; -+ -+ if (lhs.reswizzle) { -+ if (!rhs.reswizzle) -+ return false; -+ -+ if (lhs.original_src_access_mask != rhs.original_src_access_mask) -+ return false; -+ -+ for (int i = 0; i < 4; ++i) { -+ if (1 << i & lhs.original_src_access_mask) { -+ if (lhs.writemask_map[i] != rhs.writemask_map[i]) -+ return false; -+ if (lhs.read_swizzle_map[i] != rhs.read_swizzle_map[i]) -+ return false; -+ } -+ } -+ } else { -+ return !rhs.reswizzle; -+ } -+ return true; -+} -+ -+/* end namespace tgsi_array_merge */ -+} -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h -new file mode 100644 -index 0000000..c74c854 ---- /dev/null -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h -@@ -0,0 +1,116 @@ -+/* -+ * Copyright © 2017 Gert Wollny -+ * -+ * 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 MESA_GLSL_TO_TGSI_ARRAY_MERGE_H -+#define MESA_GLSL_TO_TGSI_ARRAY_MERGE_H -+ -+#include "st_glsl_to_tgsi_private.h" -+#include <iosfwd> -+ -+namespace tgsi_array_merge { -+ -+/* Helper class to merge and interleave arrays. -+ * The interface is exposed here to make unit tests possible. -+ */ -+class array_remapping { -+public: -+ -+ /** Create an invalid mapping that is used as place-holder for -+ * arrays that are not mapped at all. -+ */ -+ array_remapping(); -+ -+ /** Simple remapping that is done when the lifetimes do not -+ * overlap. -+ * @param trgt_array_id ID of the array that the new array will -+ * be interleaved with -+ */ -+ array_remapping(int trgt_array_id, unsigned src_access_mask); -+ -+ /** Component interleaving of arrays. -+ * @param target_array_id ID of the array that the new array will -+ * be interleaved with -+ * @param trgt_access_mask the component mast of the target array -+ * (the components that are already reserved) -+ * @param orig_component_mask -+ */ -+ array_remapping(int trgt_array_id, int trgt_access_mask, -+ int src_access_mask); -+ -+ /* Defines a valid remapping */ -+ bool is_valid() const {return target_id > 0;} -+ -+ /* Resolve the mapping chain so that this mapping remaps to an -+ * array that is not remapped. -+ */ -+ void finalize_mappings(array_remapping *arr_map); -+ -+ void set_target_id(int tid) {target_id = tid;} -+ -+ /* Translates the write mask to the new, interleaved component -+ * position -+ */ -+ int map_writemask(int original_src_access_mask) const; -+ -+ /* Translates all read swizzles to the new, interleaved component -+ * swizzles -+ */ -+ uint16_t map_swizzles(uint16_t original_swizzle) const; -+ -+ /** Move the read swizzles to the positiones that correspond to -+ * a changed write mask. -+ */ -+ uint16_t move_read_swizzles(uint16_t original_swizzle) const; -+ -+ unsigned target_array_id() const {return target_id;} -+ -+ int combined_access_mask() const {return summary_access_mask;} -+ -+ void print(std::ostream& os) const; -+ -+ bool is_finalized() { return finalized;} -+ -+ friend bool operator == (const array_remapping& lhs, -+ const array_remapping& rhs); -+ -+ int map_one_swizzle(int swizzle_to_map) const; -+ -+private: -+ unsigned target_id; -+ uint16_t writemask_map[4]; -+ int16_t read_swizzle_map[4]; -+ unsigned summary_access_mask:4; -+ unsigned original_src_access_mask:4; -+ int reswizzle:1; -+ int finalized:1; -+}; -+ -+inline -+std::ostream& operator << (std::ostream& os, const array_remapping& am) -+{ -+ am.print(os); -+ return os; -+} -+ -+} -+#endif --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0005-mesa-st-glsl_to_tgsi-Add-class-to-hold-array-informa.patch b/common/recipes-graphics/mesa/mesa/0005-mesa-st-glsl_to_tgsi-Add-class-to-hold-array-informa.patch deleted file mode 100644 index d139f8a9..00000000 --- a/common/recipes-graphics/mesa/mesa/0005-mesa-st-glsl_to_tgsi-Add-class-to-hold-array-informa.patch +++ /dev/null @@ -1,156 +0,0 @@ -From a454110bd60608df5e562ac5cdc43f994bb8d33f Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:09 +0100 -Subject: [PATCH 05/13] mesa/st/glsl_to_tgsi: Add class to hold array - information - -Implememt a class that holds the information required by the array merging -and interleave algorithm, namely array ID, live range, access mask, -accessed components, and the number of accessed components. - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - .../state_tracker/st_glsl_to_tgsi_array_merge.cpp | 69 ++++++++++++++++++++++ - .../state_tracker/st_glsl_to_tgsi_array_merge.h | 46 +++++++++++++++ - 2 files changed, 115 insertions(+) - -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp -index f432d93..1a455ce 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp -@@ -37,6 +37,75 @@ using std::unique_ptr; - using std::make_unique; - #endif - -+ -+array_live_range::array_live_range(): -+ id(0), -+ length(0), -+ first_access(0), -+ last_access(0), -+ component_access_mask(0), -+ used_component_count(0) -+{ -+} -+ -+array_live_range::array_live_range(unsigned aid, unsigned alength): -+ id(aid), -+ length(alength), -+ first_access(0), -+ last_access(0), -+ component_access_mask(0), -+ used_component_count(0) -+{ -+} -+ -+array_live_range::array_live_range(unsigned aid, unsigned alength, int begin, -+ int end, int sw): -+ id(aid), -+ length(alength), -+ first_access(begin), -+ last_access(end), -+ component_access_mask(sw), -+ used_component_count(util_bitcount(sw)) -+{ -+} -+ -+void array_live_range::set_live_range(int _begin, int _end) -+{ -+ set_begin(_begin); -+ set_end(_end); -+} -+ -+void array_live_range::set_access_mask(int mask) -+{ -+ component_access_mask = mask; -+ used_component_count = util_bitcount(mask); -+} -+ -+void array_live_range::merge_live_range(const array_live_range &other) -+{ -+ if (other.begin() < first_access) -+ first_access = other.begin(); -+ if (other.end() > last_access) -+ last_access = other.end(); -+} -+ -+void array_live_range::print(std::ostream& os) const -+{ -+ os << "[id:" << id -+ << ", length:" << length -+ << ", (b:" << first_access -+ << ", e:" << last_access -+ << "), sw:" << component_access_mask -+ << ", nc:" << used_component_count -+ << "]"; -+} -+ -+bool array_live_range::time_doesnt_overlap(const array_live_range& other) const -+{ -+ return (other.last_access < first_access || -+ last_access < other.first_access); -+} -+ - namespace tgsi_array_merge { - - array_remapping::array_remapping(): -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h -index c74c854..b9fb498 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h -@@ -27,6 +27,52 @@ - #include "st_glsl_to_tgsi_private.h" - #include <iosfwd> - -+/* Helper class to evaluate the required live range of an array. -+ * -+ * For arrays not only the live range must be tracked, but also the arrays -+ * length and since we want to interleave arrays, we also track an access mask. -+ * Consequently, one array can be merged into another or interleaved with -+ * another only if the target array is longer. -+ */ -+class array_live_range { -+public: -+ array_live_range(); -+ array_live_range(unsigned aid, unsigned alength); -+ array_live_range(unsigned aid, unsigned alength, int first_access, -+ int last_access, int mask); -+ -+ void set_live_range(int first_access, int last_access); -+ void set_begin(int _begin){first_access = _begin;} -+ void set_end(int _end){last_access = _end;} -+ void set_access_mask(int s); -+ void merge_live_range(const array_live_range& other); -+ -+ unsigned array_id() const {return id;} -+ int array_length() const { return length;} -+ int begin() const { return first_access;} -+ int end() const { return last_access;} -+ int access_mask() const { return component_access_mask;} -+ int used_components() const {return used_component_count;} -+ -+ bool time_doesnt_overlap(const array_live_range& other) const; -+ -+ void print(std::ostream& os) const; -+ -+private: -+ unsigned id; -+ unsigned length; -+ int first_access; -+ int last_access; -+ int component_access_mask; -+ int used_component_count; -+}; -+ -+inline -+std::ostream& operator << (std::ostream& os, const array_live_range& lt) { -+ lt.print(os); -+ return os; -+} -+ - namespace tgsi_array_merge { - - /* Helper class to merge and interleave arrays. --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0006-mesa-st-glsl_to_tgsi-Add-array-merge-logic.patch b/common/recipes-graphics/mesa/mesa/0006-mesa-st-glsl_to_tgsi-Add-array-merge-logic.patch deleted file mode 100644 index cca4609e..00000000 --- a/common/recipes-graphics/mesa/mesa/0006-mesa-st-glsl_to_tgsi-Add-array-merge-logic.patch +++ /dev/null @@ -1,462 +0,0 @@ -From 6a7b4ddd3c5759f4b6ba0a9df527e3187c6a3e50 Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:10 +0100 -Subject: [PATCH 06/13] mesa/st/glsl_to_tgsi: Add array merge logic - -Add the functions that evaluate array live range merging and array -interleaving based on the array information. - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - .../state_tracker/st_glsl_to_tgsi_array_merge.cpp | 385 ++++++++++++++++++++- - .../state_tracker/st_glsl_to_tgsi_array_merge.h | 26 +- - 2 files changed, 409 insertions(+), 2 deletions(-) - -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp -index 1a455ce..5db49d5 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp -@@ -21,6 +21,109 @@ - * DEALINGS IN THE SOFTWARE. - */ - -+/* A short overview on how the array merging works: -+ * -+ * Inputs: -+ * - per array information: live range, access mask, size -+ * - the program -+ * -+ * Output: -+ * - the program with updated array addressing -+ * -+ * Pseudo algorithm: -+ * -+ * repeat until no more successful merges were found -+ * for all pairs of arrays: -+ * if they have non-overlapping live ranges and equal access masks: -+ * - pick shorter array -+ * - merge its live range into the longer array -+ * - set its merge target array to the longer array -+ * - mark the shorter array as processed -+ * endfor -+ * for all pairs of arrays: -+ * if they have overlapping live ranges use in sum at most four components: -+ * - pick shorter array -+ * - evaluate reswizzle map to move its components into the components -+ * that are not used by the longer array -+ * - set its merge target array to the longer array -+ * - mark the shorter array as processed -+ * - bail out of for loop -+ * endfor -+ * end repeat -+ * for all pairs of arrays: -+ * if they have non-overlapping live ranges: -+ * - pick shorter array -+ * - merge its live range into the longer array -+ * - set its merge target array to the longer array -+ * - mark the shorter array as processed -+ * endfor -+ * Finalize remapping map so that target arrays are always final, i.e. have -+ * themselfes no merge target set. -+ * -+ * Example: -+ * ID | Length | Live range | access mask | target id | reswizzle -+ * ================================================================ -+ * 1 3 3-10 x___ 0 ____ -+ * 2 4 13-20 x___ 0 ____ -+ * 3 8 3-20 x___ 0 ____ -+ * 4 6 21-40 xy__ 0 ____ -+ * 5 7 12-30 xy__ 0 ____ -+ * -+ * 1. merge live ranges 1 and 2 -+ * -+ * ID | Length | Live range | access mask | target id | reswizzle -+ * ================================================================ -+ * 1 - - x___ 2 ____ -+ * 2 4 3-20 x___ 0 ____ -+ * 3 8 3-20 x___ 0 ____ -+ * 4 6 21-40 xy__ 0 ____ -+ * 5 7 12-30 xy__ 0 ____ -+ * -+ * -+ * 3. interleave 2 and 3 -+ * -+ * ID | Length | Live range | access mask | target id | reswizzle -+ * ================================================================ -+ * 1 - - x___ 2 ____ -+ * 2 - - x___ 3 _x__ -+ * 3 8 3-20 xy__ 0 ____ -+ * 4 6 21-40 xy__ 0 ____ -+ * 5 7 12-30 xy__ 0 ____ -+ * -+ * 3. merge live ranges 3 and 4 -+ * -+ * ID | Length | Live range | access mask | target id | reswizzle -+ * ================================================================ -+ * 1 - - x___ 2 ____ -+ * 2 - - x___ 3 _x__ -+ * 3 8 3-40 xy__ 0 ____ -+ * 4 - - xy__ 3 ____ -+ * 5 7 3-21 xy__ 0 ____ -+ * -+ * 4. interleave 3 and 5 -+ * -+ * ID | Length | Live range | access mask | target id | reswizzle -+ * ================================================================ -+ * 1 - - x___ 2 ____ -+ * 2 - - x___ 3 _x__ -+ * 3 8 3-40 xy__ 0 ____ -+ * 4 - - xy__ 3 ____ -+ * 5 - - xy__ 3 __xy -+ * -+ * 5. finalize remapping -+ * (Array 1 has been merged with 2 that was later interleaved, so -+ * the reswizzeling must be propagated.) -+ * -+ * ID | Length | Live range | new access mask | target id | reswizzle -+ * ================================================================ -+ * 1 - - _y__ 3 _x__ -+ * 2 - - _y__ 3 _x__ -+ * 3 8 3-40 xy__ 0 ____ -+ * 4 - - xy__ 3 ____ -+ * 5 - - __zw 3 __xy -+ * -+*/ -+ - #include "program/prog_instruction.h" - #include "util/u_math.h" - #include <ostream> -@@ -37,6 +140,14 @@ using std::unique_ptr; - using std::make_unique; - #endif - -+#define ARRAY_MERGE_DEBUG 0 -+ -+#if ARRAY_MERGE_DEBUG -+#define ARRAY_MERGE_DUMP(x) do std::cerr << x; while (0) -+#else -+#define ARRAY_MERGE_DUMP(x) -+#endif -+ - - array_live_range::array_live_range(): - id(0), -@@ -348,5 +459,277 @@ bool operator == (const array_remapping& lhs, const array_remapping& rhs) - return true; - } - --/* end namespace tgsi_array_merge */ -+static -+bool sort_by_begin(const array_live_range& lhs, const array_live_range& rhs) { -+ return lhs.begin() < rhs.begin(); -+} -+ -+/* Helper class to evaluate merging and interleaving of arrays */ -+class array_merge_evaluator { -+public: -+ typedef int (*array_merger)(array_live_range& range_1, -+ array_live_range& range_2, -+ array_remapping *_remapping); -+ -+ array_merge_evaluator(int _narrays, array_live_range *_ranges, -+ array_remapping *_remapping); -+ -+ /** Run the merge strategy on all arrays -+ * @returns number of successful merges -+ */ -+ int run(array_merger merger, bool always_restart); -+ -+private: -+ int narrays; -+ array_live_range *ranges; -+ array_remapping *remapping; -+}; -+ -+/** Execute the live range merge */ -+static -+int merge_live_range(array_live_range& range_1, array_live_range& range_2, -+ array_remapping *remapping) -+{ -+ if (range_2.time_doesnt_overlap(range_1)) { -+ if (range_1.array_length() < range_2.array_length()) -+ std::swap(range_2, range_1); -+ -+ ARRAY_MERGE_DUMP("merge " << range_2 << " into " << range_1 << "\n"); -+ -+ remapping[range_2.array_id()] = array_remapping(range_1.array_id(), -+ range_1.access_mask()); -+ range_1.merge_live_range(range_2); -+ return 1; -+ } -+ return 0; -+} -+ -+/** Merge arrays that have non-overlapping live ranges -+ * and equal access masks. -+ */ -+static -+int merge_live_range_equal_swizzle(array_live_range& range_1, -+ array_live_range& range_2, -+ array_remapping *remapping) -+{ -+ if (range_1.access_mask() == range_2.access_mask()) -+ return merge_live_range(range_1, range_2, remapping); -+ return 0; -+} -+ -+static -+int array_interleave(array_live_range& range_1, array_live_range& range_2, -+ array_remapping *remapping) -+{ -+ if ((range_2.used_components() + range_1.used_components() > 4) || -+ range_1.time_doesnt_overlap(range_2)) -+ return 0; -+ -+ if (range_1.array_length() < range_2.array_length()) -+ std::swap(range_2, range_1); -+ -+ ARRAY_MERGE_DUMP("Interleave " << range_2 << " into " << range_1 << "\n"); -+ remapping[range_2.array_id()] = array_remapping(range_1.array_id(), -+ range_1.access_mask(), -+ range_2.access_mask()); -+ range_1.merge_live_range(range_2); -+ range_1.set_access_mask(remapping[range_2.array_id()].combined_access_mask()); -+ ARRAY_MERGE_DUMP(" Interleaved is " << range_1 << "\n"); -+ return 1; -+} -+ -+/* Implementation of the helper classes follows */ -+array_merge_evaluator::array_merge_evaluator(int _narrays, -+ array_live_range *_ranges, -+ array_remapping *_remapping): -+ narrays(_narrays), -+ ranges(_ranges), -+ remapping(_remapping) -+{ -+} -+ -+int array_merge_evaluator::run(array_merger merger, bool always_restart) -+{ -+ int remaps = 0; -+ -+ for (int i = 0; i < narrays; ++i) { -+ -+ if (remapping[ranges[i].array_id()].is_valid()) -+ continue; -+ -+ for (int j = i + 1; j < narrays; ++j) { -+ -+ if (!remapping[ranges[j].array_id()].is_valid()) { -+ int n = merger(ranges[i], ranges[j], remapping); -+ if (always_restart && n) -+ return n; -+ remaps += n; -+ } -+ -+ } -+ } -+ return remaps; -+} -+ -+/* Estimate the array merging: First in a loop, arrays with equal access mask -+ * are merged then interleave arrays that together use at most four components, -+ * and finally arrays are merged regardless of access mask. -+ * @param[in] narrays number of arrays -+ * @param[in,out] alt array life times, the merge target life time will be -+ * updated with the new life time. -+ * @param[in,out] remapping track the array index remapping and reswizzeling. -+ * @returns number of merged arrays -+ */ -+bool get_array_remapping(int narrays, array_live_range *ranges, -+ array_remapping *remapping) -+{ -+ int total_remapped = 0; -+ int n_remapped; -+ -+ /* Sort by "begin of live range" so that we don't have to restart searching -+ * after every merge. -+ */ -+ std::sort(ranges, ranges + narrays, sort_by_begin); -+ array_merge_evaluator merge_evaluator(narrays, ranges, remapping); -+ -+ do { -+ -+ n_remapped = merge_evaluator.run(merge_live_range_equal_swizzle, false); -+ -+ /* try only one array interleave, if successful, another -+ * live_range merge is tried. The test MergeAndInterleave5 -+ * (mesa/st/tests/test_glsl_to_tgsi_array_merge.cpp) -+ * shows how this can result in more arrays being merged. -+ */ -+ n_remapped += merge_evaluator.run(array_interleave, true); -+ total_remapped += n_remapped; -+ -+ ARRAY_MERGE_DUMP("Remapped " << n_remapped << " arrays\n"); -+ } while (n_remapped > 0); -+ -+ total_remapped += merge_evaluator.run(merge_live_range, false); -+ ARRAY_MERGE_DUMP("Remapped a total of " << total_remapped << " arrays\n"); -+ -+ for (int i = 1; i <= narrays; ++i) { -+ if (remapping[i].is_valid()) { -+ remapping[i].finalize_mappings(remapping); -+ } -+ } -+ return total_remapped > 0; -+} -+ -+/* Remap the arrays in a TGSI program according to the given mapping. -+ * @param narrays number of arrays -+ * @param array_sizes array of arrays sizes -+ * @param map the array remapping information -+ * @param instructions TGSI program -+ * @returns number of arrays after remapping -+ */ -+int remap_arrays(int narrays, unsigned *array_sizes, -+ exec_list *instructions, -+ array_remapping *map) -+{ -+ /* re-calculate arrays */ -+#if __cplusplus < 201402L -+ int *idx_map = new int[narrays + 1]; -+ unsigned *old_sizes = new unsigned[narrays + 1]; -+#else -+ unique_ptr<int[]> idx_map = make_unique<int[]>(narrays + 1); -+ unique_ptr<unsigned[]> old_sizes = make_unique<unsigned[]>(narrays + 1); -+#endif -+ -+ memcpy(&old_sizes[0], &array_sizes[0], sizeof(unsigned) * narrays); -+ -+ /* Evaluate mapping for the array indices and update array sizes */ -+ int new_narrays = 0; -+ for (int i = 1; i <= narrays; ++i) { -+ if (!map[i].is_valid()) { -+ ++new_narrays; -+ idx_map[i] = new_narrays; -+ array_sizes[new_narrays] = old_sizes[i]; -+ } -+ } -+ -+ /* Map the array ids of merge arrays. */ -+ for (int i = 1; i <= narrays; ++i) { -+ if (map[i].is_valid()) { -+ map[i].set_target_id(idx_map[map[i].target_array_id()]); -+ } -+ } -+ -+ /* Map the array ids of merge targets that got only renumbered. */ -+ for (int i = 1; i <= narrays; ++i) { -+ if (!map[i].is_valid()) { -+ map[i].set_target_id(idx_map[i]); -+ } -+ } -+ -+ /* Update the array ids and swizzles in the registers */ -+ foreach_in_list(glsl_to_tgsi_instruction, inst, instructions) { -+ for (unsigned j = 0; j < num_inst_src_regs(inst); j++) { -+ st_src_reg& src = inst->src[j]; -+ if (src.file == PROGRAM_ARRAY && src.array_id > 0) { -+ array_remapping& m = map[src.array_id]; -+ if (m.is_valid()) { -+ src.array_id = m.target_array_id(); -+ src.swizzle = m.map_swizzles(src.swizzle); -+ } -+ } -+ } -+ for (unsigned j = 0; j < inst->tex_offset_num_offset; j++) { -+ st_src_reg& src = inst->tex_offsets[j]; -+ if (src.file == PROGRAM_ARRAY && src.array_id > 0) { -+ array_remapping& m = map[src.array_id]; -+ if (m.is_valid()) { -+ src.array_id = m.target_array_id(); -+ src.swizzle = m.map_swizzles(src.swizzle); -+ } -+ } -+ } -+ for (unsigned j = 0; j < num_inst_dst_regs(inst); j++) { -+ st_dst_reg& dst = inst->dst[j]; -+ if (dst.file == PROGRAM_ARRAY && dst.array_id > 0) { -+ array_remapping& m = map[dst.array_id]; -+ if (m.is_valid()) { -+ assert(j == 0 && -+ "remapping can only be done for single dest ops"); -+ dst.array_id = m.target_array_id(); -+ dst.writemask = m.map_writemask(dst.writemask); -+ -+ /* If the target component is moved, then the source swizzles -+ * must be moved accordingly. -+ */ -+ for (unsigned j = 0; j < num_inst_src_regs(inst); j++) { -+ st_src_reg& src = inst->src[j]; -+ src.swizzle = m.move_read_swizzles(src.swizzle); -+ } -+ } -+ } -+ } -+ } -+ -+#if __cplusplus < 201402L -+ delete[] old_sizes; -+ delete[] idx_map; -+#endif -+ -+ return new_narrays; -+} -+ - } -+ -+using namespace tgsi_array_merge; -+ -+int merge_arrays(int narrays, -+ unsigned *array_sizes, -+ exec_list *instructions, -+ struct array_live_range *arr_live_ranges) -+{ -+ array_remapping *map= new array_remapping[narrays + 1]; -+ -+ if (get_array_remapping(narrays, arr_live_ranges, map)) -+ narrays = remap_arrays(narrays, array_sizes, instructions, map); -+ -+ delete[] map; -+ return narrays; -+} -\ No newline at end of file -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h -index b9fb498..44a4027 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h -@@ -158,5 +158,29 @@ std::ostream& operator << (std::ostream& os, const array_remapping& am) - return os; - } - -+/* Apply the array remapping (internal use, exposed here for testing) */ -+ bool get_array_remapping(int narrays, array_live_range *array_live_ranges, -+ array_remapping *remapping); -+ -+/* Apply the array remapping (internal use, exposed here for testing) */ -+int remap_arrays(int narrays, unsigned *array_sizes, -+ exec_list *instructions, -+ array_remapping *map); -+ - } --#endif -+ -+/** Remap the array access to finalize the array merging and interleaving. -+ * @param[in] narrays number of input arrays, -+ * @param[in,out] array_sizes length array of input arrays, on output the -+ * array sizes will be updated according to the remapping, -+ * @param[in,out] instructions TGSI program, on output the arrays access is -+ * remapped to the new array layout, -+ * @param[in] array_live_ranges live ranges and access information of the -+ * arrays. -+ * @returns number of remaining arrays -+ */ -+int merge_arrays(int narrays, -+ unsigned *array_sizes, -+ exec_list *instructions, -+ struct array_live_range *arr_live_ranges); -+#endif -\ No newline at end of file --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0007-mesa-st-tests-Add-unit-tests-for-array-merge-helper-.patch b/common/recipes-graphics/mesa/mesa/0007-mesa-st-tests-Add-unit-tests-for-array-merge-helper-.patch deleted file mode 100644 index 368938d9..00000000 --- a/common/recipes-graphics/mesa/mesa/0007-mesa-st-tests-Add-unit-tests-for-array-merge-helper-.patch +++ /dev/null @@ -1,384 +0,0 @@ -From 16c03290ef5f59e722f610f8914edcb98b1573b6 Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:11 +0100 -Subject: [PATCH 07/13] mesa/st/tests: Add unit tests for array merge helper - classes. - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - src/mesa/state_tracker/tests/Makefile.am | 20 +- - src/mesa/state_tracker/tests/st_tests_common.h | 7 +- - .../tests/test_glsl_to_tgsi_array_merge.cpp | 296 +++++++++++++++++++++ - 3 files changed, 317 insertions(+), 6 deletions(-) - create mode 100644 src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp - -diff --git a/src/mesa/state_tracker/tests/Makefile.am b/src/mesa/state_tracker/tests/Makefile.am -index cbb7447..160f85a 100644 ---- a/src/mesa/state_tracker/tests/Makefile.am -+++ b/src/mesa/state_tracker/tests/Makefile.am -@@ -17,8 +17,10 @@ AM_CPPFLAGS = \ - - if HAVE_STD_CXX11 - if HAVE_SHARED_GLAPI --TESTS = st-renumerate-test --check_PROGRAMS = st-renumerate-test -+TESTS = st-renumerate-test \ -+ st-array-merge-test -+check_PROGRAMS = st-renumerate-test \ -+ st-array-merge-test - - check_LIBRARIES = libmesa-st-tests-common.a - endif -@@ -34,7 +36,13 @@ st_renumerate_test_SOURCES = \ - st_renumerate_test_LDFLAGS = \ - $(LLVM_LDFLAGS) - --st_renumerate_test_LDADD = \ -+st_array_merge_test_SOURCES = \ -+ test_glsl_to_tgsi_array_merge.cpp -+ -+st_array_merge_test_LDFLAGS = \ -+ $(LLVM_LDFLAGS) -+ -+st_common_LDADD = \ - libmesa-st-tests-common.a \ - $(top_builddir)/src/mesa/libmesagallium.la \ - $(top_builddir)/src/mapi/shared-glapi/libglapi.la \ -@@ -43,3 +51,9 @@ st_renumerate_test_LDADD = \ - $(top_builddir)/src/gtest/libgtest.la \ - $(GALLIUM_COMMON_LIB_DEPS) \ - $(LLVM_LIBS) -+ -+st_renumerate_test_LDADD = \ -+ $(st_common_LDADD) -+ -+st_array_merge_test_LDADD = \ -+ $(st_common_LDADD) -diff --git a/src/mesa/state_tracker/tests/st_tests_common.h b/src/mesa/state_tracker/tests/st_tests_common.h -index 0fcec62..98d227a 100644 ---- a/src/mesa/state_tracker/tests/st_tests_common.h -+++ b/src/mesa/state_tracker/tests/st_tests_common.h -@@ -24,14 +24,15 @@ - #ifndef mesa_st_tests_h - #define mesa_st_tests_h - --#include <state_tracker/st_glsl_to_tgsi_temprename.h> --#include <gtest/gtest.h> -+#include "state_tracker/st_glsl_to_tgsi_temprename.h" -+#include "state_tracker/st_glsl_to_tgsi_array_merge.h" -+#include "gtest/gtest.h" -+ - #include <utility> - - #define MP(X, W) std::make_pair(X, W) - #define MT(X,Y,Z) std::make_tuple(X,Y,Z) - -- - /* Use this to make the compiler pick the swizzle constructor below */ - struct SWZ {}; - -diff --git a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp -new file mode 100644 -index 0000000..d8a5e7f ---- /dev/null -+++ b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp -@@ -0,0 +1,296 @@ -+/* -+ * Copyright © 2017 Gert Wollny -+ * -+ * 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. -+ */ -+ -+ -+#include "st_tests_common.h" -+ -+#include "tgsi/tgsi_ureg.h" -+#include "tgsi/tgsi_info.h" -+#include "mesa/program/prog_instruction.h" -+#include "gtest/gtest.h" -+ -+#include <utility> -+#include <algorithm> -+#include <iostream> -+ -+using std::vector; -+ -+using namespace tgsi_array_merge; -+using SwizzleRemapTest=testing::Test; -+ -+TEST_F(SwizzleRemapTest, ArrayRemappingBase_x_x) -+{ -+ array_remapping map1(10, 1, 1); -+ ASSERT_EQ(map1.target_array_id(), 10u); -+ ASSERT_EQ(map1.map_writemask(1), 2); -+ ASSERT_EQ(map1.map_one_swizzle(0), 1); -+ ASSERT_EQ(map1.combined_access_mask(), 3); -+} -+ -+TEST_F(SwizzleRemapTest, ArrayRemappingBase_xy_x) -+{ -+ array_remapping map1(5, 3, 1); -+ ASSERT_EQ(map1.target_array_id(), 5u); -+ ASSERT_EQ(map1.map_writemask(1), 4); -+ ASSERT_EQ(map1.map_one_swizzle(0), 2); -+ ASSERT_EQ(map1.combined_access_mask(), 0x7); -+} -+ -+TEST_F(SwizzleRemapTest, ArrayRemappingBase_no_reswizzle) -+{ -+ array_remapping map1(5, 3); -+ ASSERT_EQ(map1.target_array_id(), 5u); -+ for (int i = 1; i < 16; ++i) -+ ASSERT_EQ(map1.map_writemask(i), i); -+ -+ for (int i = 0; i < 4; ++i) -+ ASSERT_EQ(map1.map_one_swizzle(i), i); -+} -+ -+TEST_F(SwizzleRemapTest, ArrayRemappingBase_xyz_x) -+{ -+ array_remapping map1(5, 7, 1); -+ ASSERT_EQ(map1.target_array_id(), 5u); -+ ASSERT_EQ(map1.map_writemask(1), 8); -+ ASSERT_EQ(map1.map_one_swizzle(0), 3); -+ ASSERT_EQ(map1.combined_access_mask(), 0xF); -+} -+ -+TEST_F(SwizzleRemapTest, ArrayRemappingBase_xy_xy) -+{ -+ array_remapping map1(5, 3, 3); -+ ASSERT_EQ(map1.target_array_id(), 5u); -+ ASSERT_EQ(map1.map_writemask(1), 4); -+ ASSERT_EQ(map1.map_writemask(2), 8); -+ ASSERT_EQ(map1.map_writemask(3), 0xC); -+ ASSERT_EQ(map1.map_one_swizzle(0), 2); -+ ASSERT_EQ(map1.map_one_swizzle(1), 3); -+ ASSERT_EQ(map1.combined_access_mask(), 0xF); -+} -+ -+TEST_F(SwizzleRemapTest, ArrayRemappingBase_xz_xw) -+{ -+ array_remapping map1(5, 5, 9); -+ std::cerr << map1 << "\n"; -+ ASSERT_EQ(map1.target_array_id(), 5u); -+ ASSERT_EQ(map1.map_writemask(1), 2); -+ ASSERT_EQ(map1.map_writemask(8), 8); -+ ASSERT_EQ(map1.map_writemask(9), 0xA); -+ ASSERT_EQ(map1.map_one_swizzle(0), 1); -+ ASSERT_EQ(map1.map_one_swizzle(3), 3); -+ ASSERT_EQ(map1.combined_access_mask(), 0xF); -+} -+ -+using ArrayMergeTest=testing::Test; -+ -+TEST_F(ArrayMergeTest, ArrayMergeTwoSwizzles) -+{ -+ vector<array_live_range> alt = { -+ {1, 4, 1, 5, WRITEMASK_X}, -+ {2, 4, 2, 5, WRITEMASK_X}, -+ }; -+ -+ vector<array_remapping> expect = { -+ {}, -+ {1, WRITEMASK_X, WRITEMASK_X}, -+ }; -+ -+ vector<array_remapping> result(alt.size() + 1); -+ -+ get_array_remapping(2, &alt[0], &result[0]); -+ -+ EXPECT_EQ(result[1], expect[0]); -+ EXPECT_EQ(result[2], expect[1]); -+ -+} -+ -+TEST_F(ArrayMergeTest, ArrayMergeFourSwizzles) -+{ -+ vector<array_live_range> alt = { -+ {1, 8, 1, 7, WRITEMASK_X}, -+ {2, 7, 2, 7, WRITEMASK_X}, -+ {3, 6, 3, 7, WRITEMASK_X}, -+ {4, 5, 4, 7, WRITEMASK_X}, -+ }; -+ -+ vector<array_remapping> expect = { -+ {}, -+ {1, WRITEMASK_X, WRITEMASK_X}, -+ {1, WRITEMASK_XY, WRITEMASK_X}, -+ {1, WRITEMASK_XYZ, WRITEMASK_X}, -+ }; -+ -+ vector<array_remapping> result(alt.size() + 1); -+ -+ get_array_remapping(4, &alt[0], &result[0]); -+ -+ EXPECT_EQ(result[1], expect[0]); -+ EXPECT_EQ(result[2], expect[1]); -+ EXPECT_EQ(result[3], expect[2]); -+ EXPECT_EQ(result[4], expect[3]); -+ -+} -+ -+ -+TEST_F(ArrayMergeTest, SimpleChainMerge) -+{ -+ vector<array_live_range> input = { -+ {1, 3, 1, 5, WRITEMASK_XYZW}, -+ {2, 2, 6, 7, WRITEMASK_XYZW}, -+ }; -+ -+ vector<array_remapping> expect = { -+ {}, -+ {1, WRITEMASK_XYZW}, -+ }; -+ -+ vector<array_remapping> result(3); -+ get_array_remapping(2, &input[0], &result[0]); -+ -+ for (unsigned i = 0; i < expect.size(); ++i) -+ EXPECT_EQ(result[i + 1], expect[i]); -+} -+ -+TEST_F(ArrayMergeTest, MergeAndInterleave) -+{ -+ vector<array_live_range> input = { -+ {1, 5, 1, 5, WRITEMASK_X}, -+ {2, 4, 6, 7, WRITEMASK_X}, -+ {3, 3, 1, 5, WRITEMASK_X}, -+ {4, 2, 6, 7, WRITEMASK_X}, -+ }; -+ -+ vector<array_remapping> expect = { -+ {}, -+ {1, WRITEMASK_X}, -+ {1, WRITEMASK_X, WRITEMASK_X}, -+ {1, WRITEMASK_X, WRITEMASK_X} -+ }; -+ vector<array_remapping> result(input.size() + 1); -+ get_array_remapping(input.size(), &input[0], &result[0]); -+ -+ for (unsigned i = 0; i < expect.size(); ++i) -+ EXPECT_EQ(result[i + 1], expect[i]); -+} -+ -+TEST_F(ArrayMergeTest, MergeAndInterleave2) -+{ -+ vector<array_live_range> input = { -+ {1, 5, 1, 5, WRITEMASK_X}, -+ {2, 4, 6, 7, WRITEMASK_X}, -+ {3, 3, 1, 8, WRITEMASK_XY}, -+ {4, 2, 6, 7, WRITEMASK_X}, -+ }; -+ -+ vector<array_remapping> expect = { -+ {}, -+ {1, WRITEMASK_X}, -+ {1, WRITEMASK_X, WRITEMASK_XY}, -+ {1, WRITEMASK_XYZ, WRITEMASK_X} -+ }; -+ vector<array_remapping> result(input.size() + 1); -+ get_array_remapping(input.size(), &input[0], &result[0]); -+ -+ for (unsigned i = 0; i < expect.size(); ++i) -+ EXPECT_EQ(result[i + 1], expect[i]); -+} -+ -+ -+TEST_F(ArrayMergeTest, MergeAndInterleave3) -+{ -+ vector<array_live_range> input = { -+ {1, 5, 1, 5, WRITEMASK_X}, -+ {2, 4, 6, 7, WRITEMASK_XY}, -+ {3, 3, 1, 5, WRITEMASK_X} -+ }; -+ -+ vector<array_remapping> expect = { -+ {}, -+ {1, WRITEMASK_X}, -+ {1, WRITEMASK_X, WRITEMASK_X} -+ }; -+ vector<array_remapping> result(input.size() + 1); -+ get_array_remapping(input.size(), &input[0], &result[0]); -+ -+ for (unsigned i = 0; i < expect.size(); ++i) -+ EXPECT_EQ(result[i + 1], expect[i]); -+} -+ -+TEST_F(ArrayMergeTest, MergeAndInterleave4) -+{ -+ vector<array_live_range> input = { -+ {1, 7, 1, 5, WRITEMASK_X}, -+ {2, 6, 6, 7, WRITEMASK_XY}, -+ {3, 5, 1, 5, WRITEMASK_X}, -+ {4, 4, 8, 9, WRITEMASK_XYZ}, -+ {5, 3, 8, 9, WRITEMASK_W}, -+ {6, 2, 10, 11, WRITEMASK_XYZW}, -+ }; -+ -+ vector<array_remapping> expect = { -+ {}, -+ {1, WRITEMASK_XY}, -+ {1, WRITEMASK_X, WRITEMASK_X}, -+ {1, WRITEMASK_XYZ}, -+ {1, WRITEMASK_XYZ, WRITEMASK_W}, -+ {1, WRITEMASK_XYZW} -+ }; -+ vector<array_remapping> result(input.size() + 1); -+ get_array_remapping(input.size(), &input[0], &result[0]); -+ -+ EXPECT_EQ(result[1], expect[0]); -+ EXPECT_EQ(result[2], expect[1]); -+ EXPECT_EQ(result[3], expect[2]); -+ EXPECT_EQ(result[4], expect[3]); -+ EXPECT_EQ(result[5], expect[4]); -+ EXPECT_EQ(result[6], expect[5]); -+ -+} -+ -+TEST_F(ArrayMergeTest, MergeAndInterleave5) -+{ -+ vector<array_live_range> input = { -+ {1, 7, 1, 5, WRITEMASK_X}, -+ {2, 6, 1, 3, WRITEMASK_X}, -+ {3, 5, 4, 5, WRITEMASK_X}, -+ {4, 4, 6, 10, WRITEMASK_XY}, -+ {5, 8, 1, 10, WRITEMASK_XY} -+ }; -+ -+ vector<array_remapping> expect = { -+ {5, WRITEMASK_XY, WRITEMASK_XY}, /* expect xy because of interleaving */ -+ {5, WRITEMASK_XYZ, WRITEMASK_X}, -+ {5, WRITEMASK_XYZ, WRITEMASK_X}, -+ {5, WRITEMASK_XY, WRITEMASK_XY}, -+ {} -+ }; -+ vector<array_remapping> result(input.size() + 1); -+ get_array_remapping(input.size(), &input[0], &result[0]); -+ -+ EXPECT_EQ(result[1], expect[0]); -+ EXPECT_EQ(result[2], expect[1]); -+ EXPECT_EQ(result[3], expect[2]); -+ EXPECT_EQ(result[4], expect[3]); -+ EXPECT_EQ(result[5], expect[4]); -+ -+} --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0008-mesa-st-glsl_to_tgsi-refactor-access_record-and-its-.patch b/common/recipes-graphics/mesa/mesa/0008-mesa-st-glsl_to_tgsi-refactor-access_record-and-its-.patch deleted file mode 100644 index daf71f60..00000000 --- a/common/recipes-graphics/mesa/mesa/0008-mesa-st-glsl_to_tgsi-refactor-access_record-and-its-.patch +++ /dev/null @@ -1,213 +0,0 @@ -From 3326bd12764f7921d34f50980ba34230a05e212f Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:12 +0100 -Subject: [PATCH 08/13] mesa/st/glsl_to_tgsi: refactor access_record and its - use - -* rename access_record to register_merge_record because the name is more - appropriate and we need to distinguish from the array access introduced - later. -* rename member variable acc to temp_acc -* make comparison operator in register_merge_record const - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - .../state_tracker/st_glsl_to_tgsi_temprename.cpp | 61 +++++++++++----------- - .../state_tracker/st_glsl_to_tgsi_temprename.h | 2 +- - 2 files changed, 32 insertions(+), 31 deletions(-) - -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -index 73f52cf..ae3ea17 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -@@ -884,14 +884,14 @@ register_live_range temp_comp_access::get_required_live_range() - - /* Helper class for sorting and searching the registers based - * on live ranges. */ --class access_record { -+class register_merge_record { - public: - int begin; - int end; - int reg; - bool erase; - -- bool operator < (const access_record& rhs) const { -+ bool operator < (const register_merge_record& rhs) const { - return begin < rhs.begin; - } - }; -@@ -904,30 +904,30 @@ public: - void record_read(const st_src_reg& src, int line, prog_scope *scope); - void record_write(const st_dst_reg& src, int line, prog_scope *scope); - -- void get_required_live_ranges(register_live_range *live_ranges); -+ void get_required_live_ranges(register_live_range *register_live_ranges); - private: - - int ntemps; -- temp_access *acc; -+ temp_access *temp_acc; - - }; - - access_recorder::access_recorder(int _ntemps): - ntemps(_ntemps) - { -- acc = new temp_access[ntemps]; -+ temp_acc = new temp_access[ntemps]; - } - - access_recorder::~access_recorder() - { -- delete[] acc; -+ delete[] temp_acc; - } - - void access_recorder::record_read(const st_src_reg& src, int line, - prog_scope *scope) - { - if (src.file == PROGRAM_TEMPORARY) -- acc[src.index].record_read(line, scope, src.swizzle); -+ temp_acc[src.index].record_read(line, scope, src.swizzle); - - if (src.reladdr) - record_read(*src.reladdr, line, scope); -@@ -939,7 +939,7 @@ void access_recorder::record_write(const st_dst_reg& dst, int line, - prog_scope *scope) - { - if (dst.file == PROGRAM_TEMPORARY) -- acc[dst.index].record_write(line, scope, dst.writemask); -+ temp_acc[dst.index].record_write(line, scope, dst.writemask); - - if (dst.reladdr) - record_read(*dst.reladdr, line, scope); -@@ -947,14 +947,14 @@ void access_recorder::record_write(const st_dst_reg& dst, int line, - record_read(*dst.reladdr2, line, scope); - } - --void access_recorder::get_required_live_ranges(struct register_live_range *live_ranges) -+void access_recorder::get_required_live_ranges(struct register_live_range *register_live_ranges) - { -- RENAME_DEBUG(debug_log << "=========live_ranges ==============\n"); -+ RENAME_DEBUG(debug_log << "== register live ranges ==========\n"); - for(int i = 0; i < ntemps; ++i) { - RENAME_DEBUG(debug_log<< setw(4) << i); -- live_ranges[i] = acc[i].get_required_live_range(); -- RENAME_DEBUG(debug_log << ": [" <<live_ranges[i].begin << ", " -- <<live_ranges[i].end << "]\n"); -+ register_live_ranges[i] = temp_acc[i].get_required_live_range(); -+ RENAME_DEBUG(debug_log << ": [" <<register_live_ranges[i].begin << ", " -+ <<register_live_ranges[i].end << "]\n"); - } - RENAME_DEBUG(debug_log << "==================================\n\n"); - } -@@ -972,7 +972,7 @@ static void dump_instruction(ostream& os, int line, prog_scope *scope, - */ - bool - get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, -- int ntemps, struct register_live_range *live_ranges) -+ int ntemps, struct register_live_range *register_live_ranges) - { - int line = 0; - int loop_id = 1; -@@ -1139,7 +1139,7 @@ get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, - if (cur_scope->end() < 0) - cur_scope->set_end(line - 1); - -- access.get_required_live_ranges(live_ranges); -+ access.get_required_live_ranges(register_live_ranges); - return true; - } - -@@ -1149,14 +1149,14 @@ get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, - * end points at the element past the end of the search range, and - * the array comprising [start, end) must be sorted in ascending order. - */ --static access_record* --find_next_rename(access_record* start, access_record* end, int bound) -+static register_merge_record* -+find_next_rename(register_merge_record* start, register_merge_record* end, int bound) - { - int delta = (end - start); - - while (delta > 0) { - int half = delta >> 1; -- access_record* middle = start + half; -+ register_merge_record* middle = start + half; - - if (bound <= middle->begin) { - delta = half; -@@ -1171,9 +1171,9 @@ find_next_rename(access_record* start, access_record* end, int bound) - } - - #ifndef USE_STL_SORT --static int access_record_compare (const void *a, const void *b) { -- const access_record *aa = static_cast<const access_record*>(a); -- const access_record *bb = static_cast<const access_record*>(b); -+static int register_merge_record_compare (const void *a, const void *b) { -+ const register_merge_record *aa = static_cast<const register_merge_record*>(a); -+ const register_merge_record *bb = static_cast<const register_merge_record*>(b); - return aa->begin < bb->begin ? -1 : (aa->begin > bb->begin ? 1 : 0); - } - #endif -@@ -1184,7 +1184,7 @@ void get_temp_registers_remapping(void *mem_ctx, int ntemps, - const struct register_live_range *live_ranges, - struct rename_reg_pair *result) - { -- access_record *reg_access = ralloc_array(mem_ctx, access_record, ntemps); -+ register_merge_record *reg_access = ralloc_array(mem_ctx, register_merge_record, ntemps); - - int used_temps = 0; - for (int i = 0; i < ntemps; ++i) { -@@ -1200,16 +1200,17 @@ void get_temp_registers_remapping(void *mem_ctx, int ntemps, - #ifdef USE_STL_SORT - std::sort(reg_access, reg_access + used_temps); - #else -- std::qsort(reg_access, used_temps, sizeof(access_record), access_record_compare); -+ std::qsort(reg_access, used_temps, sizeof(register_merge_record), -+ register_merge_record_compare); - #endif - -- access_record *trgt = reg_access; -- access_record *reg_access_end = reg_access + used_temps; -- access_record *first_erase = reg_access_end; -- access_record *search_start = trgt + 1; -+ register_merge_record *trgt = reg_access; -+ register_merge_record *reg_access_end = reg_access + used_temps; -+ register_merge_record *first_erase = reg_access_end; -+ register_merge_record *search_start = trgt + 1; - - while (trgt != reg_access_end) { -- access_record *src = find_next_rename(search_start, reg_access_end, -+ register_merge_record *src = find_next_rename(search_start, reg_access_end, - trgt->end); - if (src != reg_access_end) { - result[src->reg].new_reg = trgt->reg; -@@ -1228,8 +1229,8 @@ void get_temp_registers_remapping(void *mem_ctx, int ntemps, - /* Moving to the next target register it is time to remove - * the already merged registers from the search range */ - if (first_erase != reg_access_end) { -- access_record *outp = first_erase; -- access_record *inp = first_erase + 1; -+ register_merge_record *outp = first_erase; -+ register_merge_record *inp = first_erase + 1; - - while (inp != reg_access_end) { - if (!inp->erase) -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h -index 375d5b8..86c2158 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h -@@ -55,7 +55,7 @@ struct register_live_range { - */ - bool - get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, -- int ntemps, struct register_live_range *live_ranges); -+ int ntemps, struct register_live_range *register_live_ranges); - - /** Estimate the merge remapping of the registers. - * @param[in] mem_ctx a memory context that can be used with the ralloc_* --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0009-mesa-st-glsl_to_tgsi-move-evaluation-of-read-mask-up.patch b/common/recipes-graphics/mesa/mesa/0009-mesa-st-glsl_to_tgsi-move-evaluation-of-read-mask-up.patch deleted file mode 100644 index 1dd9e01c..00000000 --- a/common/recipes-graphics/mesa/mesa/0009-mesa-st-glsl_to_tgsi-move-evaluation-of-read-mask-up.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 34cd2bfe90fc659491ec3c89d9bf871615b23192 Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:13 +0100 -Subject: [PATCH 09/13] mesa/st/glsl_to_tgsi: move evaluation of read mask up - in the call hierarchy - -In preparation of the array live range tracking the evaluation of the read -mask is moved out the register live range tracking to the enclosing call -of the generalized read access tracking. - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp | 15 ++++++++------- - 1 file changed, 8 insertions(+), 7 deletions(-) - -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -index ae3ea17..4734a98 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -@@ -494,13 +494,8 @@ void temp_access::record_write(int line, prog_scope *scope, int writemask) - comp[3].record_write(line, scope); - } - --void temp_access::record_read(int line, prog_scope *scope, int swizzle) -+void temp_access::record_read(int line, prog_scope *scope, int readmask) - { -- int readmask = 0; -- for (int idx = 0; idx < 4; ++idx) { -- int swz = GET_SWZ(swizzle, idx); -- readmask |= (1 << swz) & 0xF; -- } - update_access_mask(readmask); - - if (readmask & WRITEMASK_X) -@@ -926,8 +921,14 @@ access_recorder::~access_recorder() - void access_recorder::record_read(const st_src_reg& src, int line, - prog_scope *scope) - { -+ int readmask = 0; -+ for (int idx = 0; idx < 4; ++idx) { -+ int swz = GET_SWZ(src.swizzle, idx); -+ readmask |= (1 << swz) & 0xF; -+ } -+ - if (src.file == PROGRAM_TEMPORARY) -- temp_acc[src.index].record_read(line, scope, src.swizzle); -+ temp_acc[src.index].record_read(line, scope, readmask); - - if (src.reladdr) - record_read(*src.reladdr, line, scope); --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0010-mesa-st-glsl_to_tgsi-add-class-for-array-access-trac.patch b/common/recipes-graphics/mesa/mesa/0010-mesa-st-glsl_to_tgsi-add-class-for-array-access-trac.patch deleted file mode 100644 index 629ae7cd..00000000 --- a/common/recipes-graphics/mesa/mesa/0010-mesa-st-glsl_to_tgsi-add-class-for-array-access-trac.patch +++ /dev/null @@ -1,146 +0,0 @@ -From ce713f4cae9d18dac3748183f5f92f87f92c5d13 Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:14 +0100 -Subject: [PATCH 10/13] mesa/st/glsl_to_tgsi: add class for array access - tracking - -Add a class implementing the (rather simplified) live range evaluation for -arrays. -Remark: Since the class is local and not yet used, the compiler will emit - some warnings about unused functions. - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - .../state_tracker/st_glsl_to_tgsi_temprename.cpp | 102 +++++++++++++++++++++ - 1 file changed, 102 insertions(+) - -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -index 4734a98..bdd52ac 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -@@ -22,6 +22,7 @@ - */ - - #include "st_glsl_to_tgsi_temprename.h" -+#include "st_glsl_to_tgsi_array_merge.h" - #include "tgsi/tgsi_info.h" - #include "tgsi/tgsi_strings.h" - #include "program/prog_instruction.h" -@@ -239,6 +240,27 @@ private: - bool needs_component_tracking; - }; - -+/* Class to track array access. -+ * Compared to the temporary tracking this is very simplified, mainly because -+ * with the likely indirect access one can not really establish access -+ * patterns for individual elements. Instead the life range evaluation is -+ * always for the whole array, handles only loops and the fact whether a -+ * value was accessed conditionally in a loop. -+ */ -+class array_access { -+public: -+ array_access(); -+ void record_access(int line, prog_scope *scope, int swizzle); -+ void get_required_live_range(array_live_range &lr); -+private: -+ int first_access; -+ int last_access; -+ prog_scope *first_access_scope; -+ prog_scope *last_access_scope; -+ unsigned accumulated_swizzle:4; -+ int conditional_access_in_loop:1; -+}; -+ - prog_scope_storage::prog_scope_storage(void *mc, int n): - mem_ctx(mc), - current_slot(0) -@@ -508,6 +530,86 @@ void temp_access::record_read(int line, prog_scope *scope, int readmask) - comp[3].record_read(line, scope); - } - -+array_access::array_access(): -+ first_access(-1), -+ last_access(-1), -+ first_access_scope(nullptr), -+ last_access_scope(nullptr), -+ accumulated_swizzle(0), -+ conditional_access_in_loop(false) -+{ -+} -+ -+void array_access::record_access(int line, prog_scope *scope, int swizzle) -+{ -+ if (!first_access_scope) { -+ first_access = line; -+ first_access_scope = scope; -+ } -+ last_access_scope = scope; -+ last_access = line; -+ accumulated_swizzle |= swizzle; -+ if (scope->in_ifelse_scope() && scope->innermost_loop()) -+ conditional_access_in_loop = true; -+} -+ -+void array_access::get_required_live_range(array_live_range& lr) -+{ -+ RENAME_DEBUG(debug_log << "first_access_scope=" << first_access_scope << "\n"); -+ RENAME_DEBUG(debug_log << "last_access_scope=" << last_access_scope << "\n"); -+ -+ if (first_access_scope == last_access_scope) { -+ lr.set_live_range(first_access, last_access); -+ lr.set_access_mask(accumulated_swizzle); -+ return; -+ } -+ -+ const prog_scope *shared_scope = first_access_scope; -+ const prog_scope *other_scope = last_access_scope; -+ -+ assert(shared_scope); -+ RENAME_DEBUG(debug_log << "shared_scope=" << shared_scope << "\n"); -+ -+ if (conditional_access_in_loop) { -+ const prog_scope *help = shared_scope->outermost_loop(); -+ if (help) { -+ shared_scope = help; -+ } else { -+ help = other_scope->outermost_loop(); -+ if (help) -+ other_scope = help; -+ } -+ if (first_access > shared_scope->begin()) -+ first_access = shared_scope->begin(); -+ if (last_access < shared_scope->end()) -+ last_access = shared_scope->end(); -+ } -+ -+ /* See if any of the two is the parent of the other. */ -+ if (other_scope->contains_range_of(*shared_scope)) { -+ shared_scope = other_scope; -+ } else while (!shared_scope->contains_range_of(*other_scope)) { -+ assert(shared_scope->parent()); -+ if (shared_scope->type() == loop_body) { -+ if (last_access < shared_scope->end()) -+ last_access = shared_scope->end(); -+ } -+ shared_scope = shared_scope->parent(); -+ } -+ -+ while (shared_scope != other_scope) { -+ if (other_scope->type() == loop_body) { -+ if (last_access < other_scope->end()) -+ last_access = other_scope->end(); -+ } -+ other_scope = other_scope->parent(); -+ } -+ -+ lr.set_live_range(first_access, last_access); -+ lr.set_access_mask(accumulated_swizzle); -+} -+ -+ - inline static register_live_range make_live_range(int b, int e) - { - register_live_range lt; --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0011-mesa-st-glsl_to_tgsi-add-array-life-range-evaluation.patch b/common/recipes-graphics/mesa/mesa/0011-mesa-st-glsl_to_tgsi-add-array-life-range-evaluation.patch deleted file mode 100644 index 1dee8300..00000000 --- a/common/recipes-graphics/mesa/mesa/0011-mesa-st-glsl_to_tgsi-add-array-life-range-evaluation.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 9a388d59aab6da2acee755cd304029c1e46a756e Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:15 +0100 -Subject: [PATCH 11/13] mesa/st/glsl_to_tgsi: add array life range evaluation - into tracking code - -This adds the array live range tracking harvesting the already implemented -live range tracking for temporary registers. With this patch the array live -range tracking is not yet exposed, and since some tests that track reladdr -access arrays, some array live range tracker instances need to be available, -so some are added as a placeholder in get_temp_registers_required_live_ranges. - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - .../state_tracker/st_glsl_to_tgsi_temprename.cpp | 61 +++++++++++++++++----- - 1 file changed, 49 insertions(+), 12 deletions(-) - -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -index bdd52ac..e276471 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -@@ -995,28 +995,34 @@ public: - - class access_recorder { - public: -- access_recorder(int _ntemps); -+ access_recorder(int _ntemps, int _narrays); - ~access_recorder(); - - void record_read(const st_src_reg& src, int line, prog_scope *scope); -- void record_write(const st_dst_reg& src, int line, prog_scope *scope); -+ void record_write(const st_dst_reg& src, int line, prog_scope *scope, -+ bool no_reswizzle); - -- void get_required_live_ranges(register_live_range *register_live_ranges); -+ void get_required_live_ranges(register_live_range *register_live_ranges, -+ array_live_range *array_live_ranges); - private: - - int ntemps; -+ int narrays; - temp_access *temp_acc; -- -+ array_access *array_acc; - }; - --access_recorder::access_recorder(int _ntemps): -- ntemps(_ntemps) -+access_recorder::access_recorder(int _ntemps, int _narrays): -+ ntemps(_ntemps), -+ narrays(_narrays) - { - temp_acc = new temp_access[ntemps]; -+ array_acc = new array_access[narrays]; - } - - access_recorder::~access_recorder() - { -+ delete[] array_acc; - delete[] temp_acc; - } - -@@ -1032,6 +1038,11 @@ void access_recorder::record_read(const st_src_reg& src, int line, - if (src.file == PROGRAM_TEMPORARY) - temp_acc[src.index].record_read(line, scope, readmask); - -+ if (src.file == PROGRAM_ARRAY) { -+ assert(src.array_id <= narrays); -+ array_acc[src.array_id - 1].record_access(line, scope, readmask); -+ } -+ - if (src.reladdr) - record_read(*src.reladdr, line, scope); - if (src.reladdr2) -@@ -1039,18 +1050,30 @@ void access_recorder::record_read(const st_src_reg& src, int line, - } - - void access_recorder::record_write(const st_dst_reg& dst, int line, -- prog_scope *scope) -+ prog_scope *scope, bool can_reswizzle) - { - if (dst.file == PROGRAM_TEMPORARY) - temp_acc[dst.index].record_write(line, scope, dst.writemask); - -+ if (dst.file == PROGRAM_ARRAY) { -+ assert(dst.array_id <= narrays); -+ -+ /* If the array is written as dst of a multi-dst operation, we must not -+ * reswizzle the access, because we would have to reswizzle also the -+ * other dst. For now just fill the mask to make interleaving impossible. -+ */ -+ array_acc[dst.array_id - 1].record_access(line, scope, -+ can_reswizzle ? dst.writemask: 0xF); -+ } -+ - if (dst.reladdr) - record_read(*dst.reladdr, line, scope); - if (dst.reladdr2) - record_read(*dst.reladdr2, line, scope); - } - --void access_recorder::get_required_live_ranges(struct register_live_range *register_live_ranges) -+void access_recorder::get_required_live_ranges(struct register_live_range *register_live_ranges, -+ struct array_live_range *array_live_ranges) - { - RENAME_DEBUG(debug_log << "== register live ranges ==========\n"); - for(int i = 0; i < ntemps; ++i) { -@@ -1060,6 +1083,15 @@ void access_recorder::get_required_live_ranges(struct register_live_range *regis - <<register_live_ranges[i].end << "]\n"); - } - RENAME_DEBUG(debug_log << "==================================\n\n"); -+ -+ RENAME_DEBUG(debug_log << "== array live ranges ==========\n"); -+ for(int i = 0; i < narrays; ++i) { -+ RENAME_DEBUG(debug_log<< setw(4) << i); -+ array_acc[i].get_required_live_range(array_live_ranges[i]); -+ RENAME_DEBUG(debug_log << ": [" <<array_live_ranges[i].begin() << ", " -+ << array_live_ranges[i].end() << "]\n"); -+ } -+ RENAME_DEBUG(debug_log << "==================================\n\n"); - } - - } -@@ -1084,6 +1116,10 @@ get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, - bool is_at_end = false; - int n_scopes = 1; - -+ /* Placeholder to make the reladdr tests pass, will be removed with the next patch. */ -+ int narrays = 2; -+ struct array_live_range array_live_ranges[3]; -+ - /* Count scopes to allocate the needed space without the need for - * re-allocation - */ -@@ -1100,7 +1136,7 @@ get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, - - prog_scope_storage scopes(mem_ctx, n_scopes); - -- access_recorder access(ntemps); -+ access_recorder access(ntemps, narrays); - - prog_scope *cur_scope = scopes.create(nullptr, outer_scope, 0, 0, line); - -@@ -1226,8 +1262,9 @@ get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, - for (unsigned j = 0; j < inst->tex_offset_num_offset; j++) { - access.record_read(inst->tex_offsets[j], line, cur_scope); - } -- for (unsigned j = 0; j < num_inst_dst_regs(inst); j++) { -- access.record_write(inst->dst[j], line, cur_scope); -+ unsigned ndst = num_inst_dst_regs(inst); -+ for (unsigned j = 0; j < ndst; j++) { -+ access.record_write(inst->dst[j], line, cur_scope, ndst == 1); - } - } - } -@@ -1242,7 +1279,7 @@ get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, - if (cur_scope->end() < 0) - cur_scope->set_end(line - 1); - -- access.get_required_live_ranges(register_live_ranges); -+ access.get_required_live_ranges(register_live_ranges, array_live_ranges); - return true; - } - --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0012-mesa-st-glsl_to_tgsi-Expose-array-live-range-trackin.patch b/common/recipes-graphics/mesa/mesa/0012-mesa-st-glsl_to_tgsi-Expose-array-live-range-trackin.patch deleted file mode 100644 index 0114c54f..00000000 --- a/common/recipes-graphics/mesa/mesa/0012-mesa-st-glsl_to_tgsi-Expose-array-live-range-trackin.patch +++ /dev/null @@ -1,204 +0,0 @@ -From 3669f47f03dcf696188294da78def040cffa77a2 Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Fri, 9 Feb 2018 11:11:16 +0100 -Subject: [PATCH 12/13] mesa/st/glsl_to_tgsi: Expose array live range tracking - and merging - -Rename get_temp_registers_required_live_ranges to get_required_live_ranges and -change its interface to also accomodate the live range tracking for arrays. -Remove the placeholder arrays in this function and tie the array merging. - -This makes the register spilling in piglit - glsl-1.30/execution/fs-multiple-large-local-arrays -on r600/barts unneccessary. - -Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100200 -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 25 +++++++++++++++++----- - .../state_tracker/st_glsl_to_tgsi_temprename.cpp | 13 +++++------ - .../state_tracker/st_glsl_to_tgsi_temprename.h | 19 ++++++++++------ - src/mesa/state_tracker/tests/st_tests_common.cpp | 19 ++++++++-------- - 4 files changed, 48 insertions(+), 28 deletions(-) - -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp -index 163f334..c58fac0 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp -@@ -5467,25 +5467,40 @@ glsl_to_tgsi_visitor::split_arrays(void) - next_array = n_remaining_arrays; - } - --/* Merges temporary registers together where possible to reduce the number of -- * registers needed to run a program. -+/* Merges temporary registers and arrays together where possible to reduce -+ * the number of registers needed to run a program. - * - * Produces optimal code only after copy propagation and dead code elimination - * have been run. */ - void - glsl_to_tgsi_visitor::merge_registers(void) - { -+ struct array_live_range *arr_live_ranges = NULL; -+ - struct register_live_range *reg_live_ranges = - rzalloc_array(mem_ctx, struct register_live_range, this->next_temp); - -- if (get_temp_registers_required_live_ranges(reg_live_ranges, &this->instructions, -- this->next_temp, reg_live_ranges)) { -+ if (this->next_array > 0) { -+ arr_live_ranges = new array_live_range[this->next_array]; -+ for (unsigned i = 0; i < this->next_array; ++i) -+ arr_live_ranges[i] = array_live_range(i+1, this->array_sizes[i+1]); -+ } -+ -+ -+ if (get_required_live_ranges(reg_live_ranges, &this->instructions, -+ this->next_temp, reg_live_ranges, -+ this->next_array, arr_live_ranges)) { - struct rename_reg_pair *renames = - rzalloc_array(reg_live_ranges, struct rename_reg_pair, this->next_temp); - get_temp_registers_remapping(reg_live_ranges, this->next_temp, - reg_live_ranges, renames); - rename_temp_registers(renames); -- ralloc_free(renames); -+ -+ this->next_array = merge_arrays(this->next_array, this->array_sizes, -+ &this->instructions, arr_live_ranges); -+ -+ if (arr_live_ranges) -+ delete[] arr_live_ranges; - } - ralloc_free(reg_live_ranges); - } -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -index e276471..eafe4cd 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -@@ -1102,12 +1102,13 @@ static void dump_instruction(ostream& os, int line, prog_scope *scope, - const glsl_to_tgsi_instruction& inst); - #endif - --/* Scan the program and estimate the required register live ranges. -- * live_ranges must be pre-allocated. -+/* Scan the program and estimate the required register and array live ranges. -+ * The *live_ranges must be pre-allocated. - */ - bool --get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, -- int ntemps, struct register_live_range *register_live_ranges) -+get_required_live_ranges(void *mem_ctx, exec_list *instructions, int ntemps, -+ struct register_live_range *register_live_ranges, -+ int narrays, struct array_live_range *array_live_ranges) - { - int line = 0; - int loop_id = 1; -@@ -1116,10 +1117,6 @@ get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, - bool is_at_end = false; - int n_scopes = 1; - -- /* Placeholder to make the reladdr tests pass, will be removed with the next patch. */ -- int narrays = 2; -- struct array_live_range array_live_ranges[3]; -- - /* Count scopes to allocate the needed space without the need for - * re-allocation - */ -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h -index 86c2158..e0dbc3d 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h -@@ -24,7 +24,7 @@ - #ifndef MESA_GLSL_TO_TGSI_TEMPRENAME_H - #define MESA_GLSL_TO_TGSI_TEMPRENAME_H - --#include "st_glsl_to_tgsi_private.h" -+#include "st_glsl_to_tgsi_array_merge.h" - - /** Storage to record the required live range of a temporary register - * begin == end == -1 indicates that the register can be reused without -@@ -38,9 +38,9 @@ struct register_live_range { - int end; - }; - --/** Evaluates the required live ranges of temporary registers in a shader. -- * The live range estimation can only be run sucessfully if the shader doesn't -- * call a subroutine. -+/** Evaluates the required live ranges of temporary registers and arrays in a -+ * shader. The live range estimation can only be run sucessfully if the shader -+ * doesn't call a subroutine. - * @param[in] mem_ctx a memory context that can be used with the ralloc_* - * functions - * @param[in] instructions the shader to be anlzyed -@@ -50,12 +50,19 @@ struct register_live_range { - * point to allocated memory that can hold ntemps register_live_range - * structures. On output the live ranges contains the live ranges for - * the registers with the exception of TEMP[0] -+ * @param[in] narrays number of array sreserved for this shader -+ * @param[in,out] arr_live_ranges memory location to store the estimated required -+ * live ranges for each array. The parameter must point to allocated memory -+ * that can hold narrays array_live_range structures. On output the live -+ * ranges contains the live ranges for the registers with the exception of -+ * ARRAY[0]. - * @returns: true if the lifetimes were estimated, false if not (i.e. if a - * subroutine was called). - */ - bool --get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions, -- int ntemps, struct register_live_range *register_live_ranges); -+get_required_live_ranges(void *mem_ctx, exec_list *instructions, -+ int ntemps, struct register_live_range *register_live_ranges, -+ int narrays, array_live_range *array_live_ranges); - - /** Estimate the merge remapping of the registers. - * @param[in] mem_ctx a memory context that can be used with the ralloc_* -diff --git a/src/mesa/state_tracker/tests/st_tests_common.cpp b/src/mesa/state_tracker/tests/st_tests_common.cpp -index f1e4a83..33d669d 100644 ---- a/src/mesa/state_tracker/tests/st_tests_common.cpp -+++ b/src/mesa/state_tracker/tests/st_tests_common.cpp -@@ -409,11 +409,11 @@ LifetimeEvaluatorTest::run(const vector<FakeCodeline>& code, bool& success) - { - FakeShader shader(code); - lifetime_result result(shader.get_num_temps()); -- -+ vector <array_live_range> arr(10); - success = -- get_temp_registers_required_live_ranges(mem_ctx, shader.get_program(mem_ctx), -+ get_required_live_ranges(mem_ctx, shader.get_program(mem_ctx), - shader.get_num_temps(), -- &result[0]); -+ &result[0], 9, &arr[0]); - - return result; - } -@@ -422,11 +422,11 @@ void LifetimeEvaluatorTest::run(const vector<FakeCodeline>& code, const temp_lt_ - { - FakeShader shader(code); - lifetime_result result(shader.get_num_temps()); -- -+ vector <array_live_range> arr(10); - bool success = -- get_temp_registers_required_live_ranges(mem_ctx, shader.get_program(mem_ctx), -+ get_required_live_ranges(mem_ctx, shader.get_program(mem_ctx), - shader.get_num_temps(), -- &result[0]); -+ &result[0], 9, &arr[0]); - ASSERT_TRUE(success); - ASSERT_EQ(result.size(), e.size()); - check(result, e); -@@ -478,8 +478,9 @@ void RegisterLifetimeAndRemappingTest::run(const vector<FakeCodeline>& code, - { - FakeShader shader(code); - std::vector<register_live_range> lt(shader.get_num_temps()); -- -- get_temp_registers_required_live_ranges(mem_ctx, shader.get_program(mem_ctx), -- shader.get_num_temps(), <[0]); -+ vector <array_live_range> arr(10); -+ get_required_live_ranges(mem_ctx, shader.get_program(mem_ctx), -+ shader.get_num_temps(), <[0], -+ 9, &arr[0]); - this->run(lt, expect); - } --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa/0013-mesa-st-glsl_to_tgsi-Properly-resolve-life-times-for.patch b/common/recipes-graphics/mesa/mesa/0013-mesa-st-glsl_to_tgsi-Properly-resolve-life-times-for.patch deleted file mode 100644 index aae65422..00000000 --- a/common/recipes-graphics/mesa/mesa/0013-mesa-st-glsl_to_tgsi-Properly-resolve-life-times-for.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 1e6cac33a250c63865a02b82a073457b26ddb120 Mon Sep 17 00:00:00 2001 -From: Gert Wollny <gw.fossdev@gmail.com> -Date: Tue, 6 Mar 2018 18:36:40 +0100 -Subject: [PATCH 13/13] mesa/st/glsl_to_tgsi: Properly resolve life times for - simple if/else + use constructs - -In constructs like - - while (foo) { - ... - if (a) { - ... - if (b) - foo = ... - else - foo = ... - x = foo; - ... - } - ... - } - -currently the live range estimation extends the live range of t unnecessarily -to the whole loop because it was not detected that t is only read in the -"if (a)" scope that encloses the "if (b)/else" constructs where t is written -in both branches. - -This patch corrects the minimal live range estimation and adds an according -unit test for this case. - -Signed-off-by: Gert Wollny <gw.fossdev@gmail.com> ---- - .../state_tracker/st_glsl_to_tgsi_temprename.cpp | 14 +++++++++++++ - .../tests/test_glsl_to_tgsi_lifetime.cpp | 23 ++++++++++++++++++++++ - 2 files changed, 37 insertions(+) - -diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -index eafe4cd..115dca7 100644 ---- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp -@@ -838,6 +838,20 @@ void temp_comp_access::record_else_write(const prog_scope& scope) - } else { - current_unpaired_if_write_scope = nullptr; - } -+ /* Promote the first write scope to the enclosing scope because the -+ * current IF/ELSE pair is now irrelevant for the analysis. This is -+ * needed to obtain the minimum live range for t in constructs like: -+ * { -+ * var t; -+ * if (a) -+ * t = ... -+ * else -+ * t = ... -+ * x = t; -+ * ... -+ * } -+ */ -+ first_write_scope = scope.parent(); - - /* If some parent is IF/ELSE and in a loop then propagate the - * write to that scope. Otherwise the write is unconditional -diff --git a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp -index dbf74cc..a665d9d 100644 ---- a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp -+++ b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp -@@ -794,6 +794,29 @@ TEST_F(LifetimeEvaluatorExactTest, WriteInIfElseBranchSecondIfInLoop) - run (code, temp_lt_expect({{-1,-1}, {2,9}})); - } - -+/* -+ Test for write in IF and ELSE and read in enclosing IF in loop. -+*/ -+ -+TEST_F(LifetimeEvaluatorExactTest, DeeplyNestedinLoop) -+{ -+ const vector<FakeCodeline> code = { -+ { TGSI_OPCODE_BGNLOOP }, -+ { TGSI_OPCODE_UIF, {}, {in0}, {}}, -+ { TGSI_OPCODE_FSEQ, {1}, {in1,in2}, {}}, -+ { TGSI_OPCODE_UIF, {}, {1}, {}}, -+ { TGSI_OPCODE_MOV, {2}, {in1}, {}}, -+ { TGSI_OPCODE_ELSE }, -+ { TGSI_OPCODE_MOV, {2}, {in2}, {}}, -+ { TGSI_OPCODE_ENDIF }, -+ { TGSI_OPCODE_MOV, {3}, {2}, {}}, -+ { TGSI_OPCODE_ENDIF }, -+ { TGSI_OPCODE_ADD, {out0}, {3, in1}, {}}, -+ { TGSI_OPCODE_ENDLOOP } -+ }; -+ run (code, temp_lt_expect({{-1,-1}, {2,3}, {4, 8}, {0,11}})); -+} -+ - /** Regression test for bug #104803, - * Read and write in if/else path outside loop and later read in conditional - * within a loop. The first write is to be considered the dominant write. --- -2.7.4 - diff --git a/common/recipes-graphics/mesa/mesa_git.bb b/common/recipes-graphics/mesa/mesa_git.bb deleted file mode 100644 index f7e4bc75..00000000 --- a/common/recipes-graphics/mesa/mesa_git.bb +++ /dev/null @@ -1,92 +0,0 @@ -require recipes-graphics/mesa/${BPN}.inc - -S = "${WORKDIR}/git" - -DEPENDS_append = " python-mako-native" -inherit pythonnative - -SRCREV_amd = "d07a49fb1840bb441e600ce942cb0088e7ea15c7" -LIC_FILES_CHKSUM_amd = "file://docs/license.html;md5=725f991a1cc322aa7a0cd3a2016621c4" -PV_amd = "18.1.0+git${SRCPV}" - -DEPENDS_append_amd = " libvdpau libomxil" - -PACKAGECONFIG[va] = "--enable-va,--disable-va,libva" -PACKAGECONFIG_append_amd = " xvmc gallium r600 gallium-llvm xa" -PACKAGECONFIG_append_radeon = " va" -PACKAGECONFIG_append_amdgpu = " va" - -PACKAGECONFIG_remove_amd = "vulkan" -PACKAGECONFIG_remove_amdfalconx86 = "xvmc" - -LIBVA_PLATFORMS = "libva" -LIBVA_PLATFORMS .= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', ' libva-x11', '', d)}" -LIBVA_PLATFORMS .= "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', ' libva-wayland', '', d)}" -LIBVA_PLATFORMS .= "${@bb.utils.contains('DISTRO_FEATURES', 'opengl', ' libva-gl', '', d)}" -RDEPENDS_mesa-megadriver += "${@bb.utils.contains('PACKAGECONFIG', 'va', '${LIBVA_PLATFORMS}', '', d)}" - -MESA_LLVM_RELEASE_amd = "6.0" - -SRC_URI_amd = "git://anongit.freedesktop.org/mesa/mesa;branch=master \ - file://0001-st-omx-enc-fix-blit-setup-for-YUV-LoadImage.patch \ - file://0002-mesa-st-glsl_to_tgsi-Split-arrays-who-s-elements-are.patch \ - file://0003-mesa-st-glsl_to_tgsi-rename-lifetime-to-register_liv.patch \ - file://0004-mesa-st-Add-helper-classes-for-array-merging-and-int.patch \ - file://0005-mesa-st-glsl_to_tgsi-Add-class-to-hold-array-informa.patch \ - file://0006-mesa-st-glsl_to_tgsi-Add-array-merge-logic.patch \ - file://0007-mesa-st-tests-Add-unit-tests-for-array-merge-helper-.patch \ - file://0008-mesa-st-glsl_to_tgsi-refactor-access_record-and-its-.patch \ - file://0009-mesa-st-glsl_to_tgsi-move-evaluation-of-read-mask-up.patch \ - file://0010-mesa-st-glsl_to_tgsi-add-class-for-array-access-trac.patch \ - file://0011-mesa-st-glsl_to_tgsi-add-array-life-range-evaluation.patch \ - file://0012-mesa-st-glsl_to_tgsi-Expose-array-live-range-trackin.patch \ - file://0013-mesa-st-glsl_to_tgsi-Properly-resolve-life-times-for.patch \ - file://0001-configure.ac-obey-llvm_prefix-if-available.patch \ - file://0001-configure.ac-adjust-usage-of-LLVM-flags.patch" - -EXTRA_OECONF_append_amd = " \ - --enable-vdpau \ - --enable-osmesa \ - --enable-glx \ - --enable-omx-bellagio \ - --with-omx-bellagio-libdir=${libdir}/bellagio \ - --enable-texture-float" - -# Package all the libXvMC gallium extensions together -# they provide the shared lib libXvMCGallium and splitting -# them up creates trouble in rpm packaging -PACKAGES =+ "libxvmcgallium-${PN} libxvmcgallium-${PN}-dev" -FILES_libxvmcgallium-${PN} = "${libdir}/libXvMC*${SOLIBS}" -FILES_libxvmcgallium-${PN}-dev = "${libdir}/libXvMC*${SOLIBSDEV} \ - ${libdir}/libXvMC*.la" - -PACKAGES =+ "libvdpau-${PN} libvdpau-${PN}-dev" -FILES_libvdpau-${PN} = "${libdir}/vdpau/libvdpau*${SOLIBS}" -FILES_libvdpau-${PN}-dev = "${libdir}/vdpau/libvdpau*${SOLIBSDEV} \ - ${libdir}/vdpau/libvdpau*.la" -FILES_${PN}-dbg += "${libdir}/vdpau/.debug" - -# -# libomx files are non-versioned so we put *.so directly in the -# main package as opposed to the -dev package. -# -PACKAGES =+ "libomx-${PN} libomx-${PN}-dev" -FILES_libomx-${PN} = "${libdir}/bellagio/libomx_*.so" -FILES_libomx-${PN}-dev = "${libdir}/bellagio/libomx_*.la" -FILES_${PN}-dbg += "${libdir}/bellagio/.debug" - -# Set DRIDRIVERS with anonymous python so we can effectively -# override the _append_x86-64 assignement from mesa.inc. -python () { - d.setVar("DRIDRIVERS", "swrast,radeon") - d.setVar("GALLIUMDRIVERS", "swrast,r300,r600,radeonsi") -} - -#because we cannot rely on the fact that all apps will use pkgconfig, -#make eglplatform.h independent of MESA_EGL_NO_X11_HEADER -do_install_append() { - if ${@bb.utils.contains('PACKAGECONFIG', 'egl', 'true', 'false', d)}; then - sed -i -e 's/^#if defined(MESA_EGL_NO_X11_HEADERS)$/#if defined(MESA_EGL_NO_X11_HEADERS) || ${@bb.utils.contains('PACKAGECONFIG', 'x11', '0', '1', d)}/' ${D}${includedir}/EGL/eglplatform.h - fi -} - |