mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-21 11:22:42 +00:00
[spv-in] Permit pointers to runtime arrays only in StorageBuffer. (#1522)
* [spv-in] Change shadow.spv test input to use StorageBuffer. The ecosystem around Naga will generally not be able to use Vulkan adapters that don't support the SPV_KHR_storage_buffer_storage_class (which was incorporated into SPIR-V 1.3), so we can assume it is present. Changing the test not to use runtime-sized arrays in the Uniform storage class will allow Naga to tighten up some validation checks. * [spv-in] Permit pointers to runtime arrays only in StorageBuffer. Fixes #1519.
This commit is contained in:
parent
eda078d736
commit
e69a70bfb7
@ -41,6 +41,8 @@ pub enum Error {
|
||||
UnsupportedControlFlow(spirv::Word),
|
||||
#[error("unsupported binary operator %{0}")]
|
||||
UnsupportedBinaryOperator(spirv::Word),
|
||||
#[error("Naga supports OpTypeRuntimeArray in the StorageBuffer storage class only")]
|
||||
UnsupportedRuntimeArrayStorageClass,
|
||||
#[error("unknown binary operator {0:?}")]
|
||||
UnknownBinaryOperator(spirv::Op),
|
||||
#[error("unknown relational function {0:?}")]
|
||||
|
@ -3881,7 +3881,8 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
|
||||
let decor = self.future_decor.remove(&id);
|
||||
let base_lookup_ty = self.lookup_type.lookup(type_id)?;
|
||||
let class = if let Some(class) = module.types[base_lookup_ty.handle].inner.pointer_class() {
|
||||
let base_inner = &module.types[base_lookup_ty.handle].inner;
|
||||
let class = if let Some(class) = base_inner.pointer_class() {
|
||||
class
|
||||
} else if self
|
||||
.lookup_storage_buffer_types
|
||||
@ -3897,6 +3898,22 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
}
|
||||
};
|
||||
|
||||
// We don't support pointers to runtime-sized arrays in the `Uniform`
|
||||
// storage class with the `BufferBlock` decoration. Runtime-sized arrays
|
||||
// should be in the StorageBuffer class.
|
||||
if let crate::TypeInner::Array {
|
||||
size: crate::ArraySize::Dynamic,
|
||||
..
|
||||
} = *base_inner
|
||||
{
|
||||
match class {
|
||||
crate::StorageClass::Storage { .. } => {}
|
||||
_ => {
|
||||
return Err(Error::UnsupportedRuntimeArrayStorageClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't bother with pointer stuff for `Handle` types.
|
||||
let lookup_ty = if class == crate::StorageClass::Handle {
|
||||
base_lookup_ty.clone()
|
||||
|
Binary file not shown.
@ -200,21 +200,33 @@
|
||||
name: None,
|
||||
inner: Pointer(
|
||||
base: 19,
|
||||
class: Uniform,
|
||||
class: Storage(
|
||||
access: (
|
||||
bits: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
name: None,
|
||||
inner: Pointer(
|
||||
base: 18,
|
||||
class: Uniform,
|
||||
class: Storage(
|
||||
access: (
|
||||
bits: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
name: None,
|
||||
inner: Pointer(
|
||||
base: 17,
|
||||
class: Uniform,
|
||||
class: Storage(
|
||||
access: (
|
||||
bits: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
@ -235,14 +247,22 @@
|
||||
name: None,
|
||||
inner: Pointer(
|
||||
base: 4,
|
||||
class: Uniform,
|
||||
class: Storage(
|
||||
access: (
|
||||
bits: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
name: None,
|
||||
inner: Pointer(
|
||||
base: 1,
|
||||
class: Uniform,
|
||||
class: Storage(
|
||||
access: (
|
||||
bits: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user