HLSL-IR: Use stable_sort to sort members in ShaderIO (part 2)
I only updated one of the two calls to std::sort in my last CL:
https://dawn-review.googlesource.com/c/dawn/+/212355
Bug: 364865292
Bug: 376052018
Change-Id: I7c9e2ac4637cda98d8c1349cfb7ec6dd5b5a815f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/212738
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/hlsl/writer/raise/shader_io.cc b/src/tint/lang/hlsl/writer/raise/shader_io.cc
index 81d1db2..b19edf2 100644
--- a/src/tint/lang/hlsl/writer/raise/shader_io.cc
+++ b/src/tint/lang/hlsl/writer/raise/shader_io.cc
@@ -295,8 +295,10 @@
}
// Sort the struct members to satisfy HLSL interfacing matching rules.
- std::sort(output_data.begin(), output_data.end(),
- [&](auto& x, auto& y) { return StructMemberComparator(x, y); });
+ // We use stable_sort so that two members with the same attributes maintain their relative
+ // ordering (e.g. kClipDistance).
+ std::stable_sort(output_data.begin(), output_data.end(),
+ [&](auto& x, auto& y) { return StructMemberComparator(x, y); });
output_indices.Resize(outputs.Length());
output_values.Resize(outputs.Length(), nullptr);