Skip to content

Commit

Permalink
Fix panic for non-contiguous push constants ranges (#2654)
Browse files Browse the repository at this point in the history
* Add failing test case for push_constant_ranges_disjoint

* Fix failing test case for push_constant_ranges_disjoint
  • Loading branch information
daanmichiels authored Feb 14, 2025
1 parent f498b74 commit 96c991a
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions vulkano/src/pipeline/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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!();
Expand Down

0 comments on commit 96c991a

Please sign in to comment.