diff options
author | Gert Wollny <[email protected]> | 2018-06-05 22:26:47 +0200 |
---|---|---|
committer | Gert Wollny <[email protected]> | 2018-08-11 12:32:42 +0200 |
commit | d8c2119f9b0b257a23ceb398f6d0d78da916417e (patch) | |
tree | 080c906a4dea542e48b183688e1eff064450a993 /src/mesa | |
parent | c317d0ab54fdc2f25bd4460034d3a375654c40cb (diff) |
mesa/st/glsl_to_tgsi: Expose array live range tracking and merging
This patch ties in the array split, merge, and interleave code.
shader-db changes in the TGSI code are:
original code | array-merge | change
mean max | mean max | best mean % worst
-----------------------------------------------------------
arrays 0.05 2 | 0.00 0 | -2 -100 0
total temps 5.05 21 | 4.92 20 | -15 -2.59 1
instr 55.33 988 | 55.20 988 | -15 -0.24 0
Evaluation:
Run shader-db in single thread mode (otherwise the output is
not ordered and the best and worst column don't make sense) to
get results pre-stats.txt and post-stats.txt. Then using
python pandas:
import pandas as pd
old_stats = pd.read_csv('pre-stats.txt')
new_stats = pd.read_csv('post-stats.txt')
omean = old_stats.mean()
omax = old_stats.max()
nmean = new_stats.mean()
nmax = new_stats.max()
delta = new_stats - old_stats
pd.concat([omean, omax, nmean, nmax, delta.min(),
delta.mean()/old_stats.mean()*100, delta.max()],
axis=1, keys=['mean', 'max', 'mean', 'max', 'best',
'avg change %', 'worst'])
v4: - Correct typo and add bugs that are fixed by this series.
- Update stats and describe stats evaluation
Bugzilla:
https://bugs.freedesktop.org/show_bug.cgi?id=105371
https://bugs.freedesktop.org/show_bug.cgi?id=100200
Signed-off-by: Gert Wollny <[email protected]>
Acked-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 19 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h | 5 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp | 7 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h | 11 | ||||
-rw-r--r-- | src/mesa/state_tracker/tests/st_tests_common.cpp | 15 |
5 files changed, 40 insertions, 17 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 3af7333ebd3..a2083a4f856 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5593,17 +5593,32 @@ glsl_to_tgsi_visitor::split_arrays(void) 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 (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_temp_registers_required_live_ranges(reg_live_ranges, &this->instructions, - this->next_temp, reg_live_ranges)) { + 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_array_merge.h b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h index abf58c307a6..7d52d095cfb 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 @@ -146,6 +146,9 @@ public: const array_remapping& rhs); private: + + void interleave(int trgt_access_mask, int src_access_mask); + unsigned target_id; int8_t read_swizzle_map[4]; }; @@ -182,4 +185,4 @@ 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 +#endif 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 2726e9ddcab..e1519ef3ca3 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp @@ -1121,7 +1121,8 @@ 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 *register_live_ranges) + 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; @@ -1130,10 +1131,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 tests pass */ - 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 5a812072f93..c70cd888191 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 @@ -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); + 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 ef2513a5995..91b98988091 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), - shader.get_num_temps(), - &result[0]); + shader.get_num_temps(), + &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), 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()); - + vector <array_live_range> arr(10); get_temp_registers_required_live_ranges(mem_ctx, shader.get_program(mem_ctx), - shader.get_num_temps(), <[0]); + shader.get_num_temps(), <[0], + 9, &arr[0]); this->run(lt, expect); } |