vkd3d-shader/ir: Sort loop intervals.

This commit is contained in:
Giovanni Mascellani 2024-02-06 14:02:59 +01:00 committed by Alexandre Julliard
parent 070c4af8b3
commit f2b2040ff6
Notes: Alexandre Julliard 2024-03-12 22:56:24 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Conor McCarthy (@cmccarthy)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/698

View File

@ -3766,6 +3766,20 @@ fail:
return ret; return ret;
} }
/* Sort loop intervals first by ascending begin time and then by
* descending end time, so that inner intervals appear after outer
* ones and disjoint intervals appear in their proper order. */
static int compare_loop_intervals(const void *ptr1, const void *ptr2)
{
const struct cfg_loop_interval *interval1 = ptr1;
const struct cfg_loop_interval *interval2 = ptr2;
if (interval1->begin != interval2->begin)
return vkd3d_u32_compare(interval1->begin, interval2->begin);
return -vkd3d_u32_compare(interval1->end, interval2->end);
}
static enum vkd3d_result vsir_cfg_generate_synthetic_loop_intervals(struct vsir_cfg *cfg) static enum vkd3d_result vsir_cfg_generate_synthetic_loop_intervals(struct vsir_cfg *cfg)
{ {
enum vkd3d_result ret; enum vkd3d_result ret;
@ -3879,6 +3893,8 @@ static enum vkd3d_result vsir_cfg_generate_synthetic_loop_intervals(struct vsir_
} }
} }
qsort(cfg->loop_intervals, cfg->loop_interval_count, sizeof(*cfg->loop_intervals), compare_loop_intervals);
if (TRACE_ON()) if (TRACE_ON())
for (i = 0; i < cfg->loop_interval_count; ++i) for (i = 0; i < cfg->loop_interval_count; ++i)
TRACE("%s loop interval %u - %u\n", cfg->loop_intervals[i].synthetic ? "Synthetic" : "Natural", TRACE("%s loop interval %u - %u\n", cfg->loop_intervals[i].synthetic ? "Synthetic" : "Natural",