Add interface entry for color index, check during overlap testing (#2333)

This commit is contained in:
Aspen 2023-09-15 13:22:55 -07:00 committed by GitHub
parent 4d17a7392d
commit 80ab3a829e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -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,

View File

@ -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,
@ -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",