Fix panic for non-contiguous push constants ranges (#2654)

* Add failing test case for push_constant_ranges_disjoint

* Fix failing test case for push_constant_ranges_disjoint
This commit is contained in:
Daan Michiels 2025-02-14 15:14:02 +00:00 committed by GitHub
parent f498b746cb
commit 96c991ab7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -196,16 +196,19 @@ impl PipelineLayout {
stages |= range.stages;
}
}
// finished all stages
if stages.is_empty() {
if !stages.is_empty() {
push_constant_ranges_disjoint.push(PushConstantRange {
stages,
offset: min_offset,
size: max_offset - min_offset,
});
}
if max_offset == u32::MAX {
break;
}
push_constant_ranges_disjoint.push(PushConstantRange {
stages,
offset: min_offset,
size: max_offset - min_offset,
});
// prepare for next range
min_offset = max_offset;
}
@ -1403,6 +1406,39 @@ mod tests {
},
][..],
),
// input:
// - `0..8`, stage=vertex
// - `16..32`, stage=fragment
//
// output:
// - `0..8`, stage=vertex
// - `16..32`, stage=fragment
(
&[
PushConstantRange {
stages: ShaderStages::VERTEX,
offset: 0,
size: 8,
},
PushConstantRange {
stages: ShaderStages::FRAGMENT,
offset: 16,
size: 16,
},
][..],
&[
PushConstantRange {
stages: ShaderStages::VERTEX,
offset: 0,
size: 8,
},
PushConstantRange {
stages: ShaderStages::FRAGMENT,
offset: 16,
size: 16,
},
][..],
),
];
let (device, _) = gfx_dev_and_queue!();