Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl_codegen.c:
- for (i = 0; i < component_count; ++i)
vkd3d_free(var_def);vkd3d_free(var_def->traces[i].records);
}
+static struct copy_propagation_value *copy_propagation_get_value_at_time(
struct copy_propagation_component_trace *trace, unsigned int time)
+{
- int r;
- for (r = trace->record_count - 1; r >= 0; --r)
- {
if (trace->records[r].timestamp < time)
return &trace->records[r];
- }
If I am not mistaken timestamps are monotonic here. I wonder whether a binary search might be more efficient, at least when looking for the load referenced by a swizzle (which might be much earlier in the code).
Just thinking loudly, though, I think the code as is is fine until we find evidence of the contrary. It might even be that the binary search is detrimental, if loads referenced by swizzles end up being close to the swizzles themselves. It depends on how much history we have to "unwind" on average.