Skip to content

Commit 8094ad1

Browse files
amaioranoDawn LUCI CQ
authored andcommitted
HLSL-IR: Use stable_sort to sort members in ShaderIO
Because we may add two members with the same kClipDistances attribute, we need to make sure the relative ordering of the two members remains the same. Bug: 364865292 Change-Id: Iea56c3236e7e29ec9ef3de464b08dff22941cf08 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/212355 Auto-Submit: Antonio Maiorano <[email protected]> Reviewed-by: dan sinclair <[email protected]> Commit-Queue: dan sinclair <[email protected]>
1 parent 997865f commit 8094ad1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/tint/lang/hlsl/writer/raise/shader_io.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,10 @@ struct StateImpl : core::ir::transform::ShaderIOBackendState {
213213
input_indices.Resize(input_data.Length());
214214

215215
// Sort the struct members to satisfy HLSL interfacing matching rules.
216-
std::sort(input_data.begin(), input_data.end(),
217-
[&](auto& x, auto& y) { return StructMemberComparator(x, y); });
216+
// We use stable_sort so that two members with the same attributes maintain their relative
217+
// ordering (e.g. kClipDistance).
218+
std::stable_sort(input_data.begin(), input_data.end(),
219+
[&](auto& x, auto& y) { return StructMemberComparator(x, y); });
218220

219221
Vector<core::type::Manager::StructMemberDesc, 4> input_struct_members;
220222
for (auto& input : input_data) {

0 commit comments

Comments
 (0)