Skip to content

Commit

Permalink
Add interface entry for color index, check during overlap testing (vu…
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzzyzilla authored and hakolao committed Feb 20, 2024
1 parent c891390 commit 5192481
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 4 additions & 0 deletions vulkano/src/shader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,10 @@ pub struct ShaderInterfaceEntry {
/// The location slot that the variable starts at.
pub location: u32,

/// The index within the location slot that the variable is located.
/// Only meaningful for fragment outputs.
pub index: u32,

/// The component slot that the variable starts at. Must be in the range 0..=3.
pub component: u32,

Expand Down
22 changes: 17 additions & 5 deletions vulkano/src/shader/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,12 +1197,23 @@ fn shader_interface(
_ => None,
})
.unwrap_or(0);
let index = id_info
.iter_decoration()
.find_map(|instruction| match *instruction {
Instruction::Decorate {
decoration: Decoration::Index { index },
..
} => Some(index),
_ => None,
})
.unwrap_or(0);

let ty = shader_interface_type_of(spirv, result_type_id, ignore_first_array);
assert!(ty.num_elements >= 1);

Some(ShaderInterfaceEntry {
location,
index,
component,
ty,
name,
Expand All @@ -1213,11 +1224,12 @@ fn shader_interface(
// Checking for overlapping elements.
for (offset, element1) in elements.iter().enumerate() {
for element2 in elements.iter().skip(offset + 1) {
if element1.location == element2.location
|| (element1.location < element2.location
&& element1.location + element1.ty.num_locations() > element2.location)
|| (element2.location < element1.location
&& element2.location + element2.ty.num_locations() > element1.location)
if element1.index == element2.index
&& (element1.location == element2.location
|| (element1.location < element2.location
&& element1.location + element1.ty.num_locations() > element2.location)
|| (element2.location < element1.location
&& element2.location + element2.ty.num_locations() > element1.location))
{
panic!(
"The locations of attributes `{:?}` ({}..{}) and `{:?}` ({}..{}) overlap",
Expand Down

0 comments on commit 5192481

Please # to comment.