Procházet zdrojové kódy

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: d8c2119f9b
  mesa/st/glsl_to_tgsi: Expose array live range tracking and merging
Signed-off-by: Gert Wollny <gw.fossdev@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
tags/18.3-branchpoint
Gert Wollny před 7 roky
rodič
revize
1560c58b12

+ 1
- 1
src/mesa/state_tracker/st_glsl_to_tgsi.cpp Zobrazit soubor

@@ -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]);
}



+ 5
- 5
src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp Zobrazit soubor

@@ -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;
}
}


Načítá se…
Zrušit
Uložit