Skip to content

Commit

Permalink
Revert "Make shader write&read storage buffers match non readonly lay…
Browse files Browse the repository at this point in the history
…outs (gfx-rs#3893)"

This reverts commit 17143c1.
  • Loading branch information
teoxoy committed Jul 27, 2023
1 parent 95f2ca7 commit 2ac009b
Showing 1 changed file with 1 addition and 70 deletions.
71 changes: 1 addition & 70 deletions wgpu-core/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ impl Resource {
)
}
};
if !address_space_matches(self.class, class) {
if self.class != class {
return Err(BindingError::WrongAddressSpace {
binding: class,
shader: self.class,
Expand Down Expand Up @@ -1237,72 +1237,3 @@ impl Interface {
Ok(outputs)
}
}

fn address_space_matches(shader: naga::AddressSpace, binding: naga::AddressSpace) -> bool {
match (shader, binding) {
(
naga::AddressSpace::Storage {
access: access_shader,
},
naga::AddressSpace::Storage {
access: access_pipeline,
},
) => {
// Allow read- and write-only usages to match read-write layouts:
(access_shader & access_pipeline) == access_shader
}
(a, b) => a == b,
}
}

#[cfg(test)]
mod test {
use super::address_space_matches;

#[test]
fn address_space_matches_correctly() {
assert!(address_space_matches(
naga::AddressSpace::Uniform,
naga::AddressSpace::Uniform
));

assert!(!address_space_matches(
naga::AddressSpace::Uniform,
naga::AddressSpace::Storage {
access: naga::StorageAccess::LOAD
}
));

let test_cases = [
(naga::StorageAccess::LOAD, naga::StorageAccess::LOAD, true),
(naga::StorageAccess::STORE, naga::StorageAccess::LOAD, false),
(naga::StorageAccess::LOAD, naga::StorageAccess::STORE, false),
(naga::StorageAccess::STORE, naga::StorageAccess::STORE, true),
(
naga::StorageAccess::LOAD | naga::StorageAccess::STORE,
naga::StorageAccess::LOAD | naga::StorageAccess::STORE,
true,
),
(
naga::StorageAccess::STORE,
naga::StorageAccess::LOAD | naga::StorageAccess::STORE,
true,
),
(
naga::StorageAccess::LOAD,
naga::StorageAccess::LOAD | naga::StorageAccess::STORE,
true,
),
];

for (shader, binding, expect_match) in test_cases {
assert_eq!(
expect_match,
address_space_matches(
naga::AddressSpace::Storage { access: shader },
naga::AddressSpace::Storage { access: binding }
)
);
}
}
}

0 comments on commit 2ac009b

Please sign in to comment.