diff options
author | Gert Wollny <[email protected]> | 2018-08-15 19:30:59 +0200 |
---|---|---|
committer | Gert Wollny <[email protected]> | 2018-08-16 08:52:26 +0200 |
commit | 1560c58b121763a21de7f883724aaa10bf37297c (patch) | |
tree | 1cd84fdf4d7b4c1a7432aef572532b35914e57fd | |
parent | 9a96bf0ecd071219cb975fbd64f5c68849fd5697 (diff) |
mesa/st: fix array indices off-by-one error in remapping
When moving the array sizes from the old list to the new one it was
not taken into account that the array indices start with one, but the
array_size array started at index zero, which resulted in incorrect array
sizes when arrays were merged. Correct this by copying the array_size
values of the retained arrays with an offset of -1.
Also fix whitespaces for the replaced lines.
Fixes: d8c2119f9b0b257a23ceb398f6d0d78da916417e
mesa/st/glsl_to_tgsi: Expose array live range tracking and merging
Signed-off-by: Gert Wollny <[email protected]>
Reviewed-by: Dave Airlie <[email protected]>
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 988f3ca83ee..7b96947c607 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5601,7 +5601,7 @@ glsl_to_tgsi_visitor::merge_registers(void) 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]); + arr_live_ranges[i] = array_live_range(i+1, this->array_sizes[i]); } 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 f95b1fac7b7..1431824369e 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 @@ -587,10 +587,10 @@ int remap_arrays(int narrays, unsigned *array_sizes, /* re-calculate arrays */ #if __cplusplus < 201402L int *idx_map = new int[narrays + 1]; - unsigned *old_sizes = new unsigned[narrays + 1]; + unsigned *old_sizes = new unsigned[narrays]; #else unique_ptr<int[]> idx_map = make_unique<int[]>(narrays + 1); - unique_ptr<unsigned[]> old_sizes = make_unique<unsigned[]>(narrays + 1); + unique_ptr<unsigned[]> old_sizes = make_unique<unsigned[]>(narrays); #endif memcpy(&old_sizes[0], &array_sizes[0], sizeof(unsigned) * narrays); @@ -599,9 +599,9 @@ int remap_arrays(int narrays, unsigned *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]; + ++new_narrays; + array_sizes[new_narrays-1] = old_sizes[i-1]; + idx_map[i] = new_narrays; } } |