mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-28 09:09:19 +01:00
[spv-in] work around integer built-ins for compute
This commit is contained in:
1 parent
2045a4a7be
commit
e92b35725c
2 files changed
+25
-15
No files matched your search
@@ -4,6 +4,8 @@ SNAPSHOTS_IN=tests/in
|
||||
SNAPSHOTS_OUT=tests/out
|
||||
|
||||
all:
|
||||
cargo test --all-features
|
||||
cargo clippy --all-features
|
||||
|
||||
clean:
|
||||
rm *.metal *.air *.metallib *.vert *.frag *.comp *.spv
|
||||
|
||||
+23
-15
@@ -2690,26 +2690,34 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
// SPIR-V only cares about some of the built-in types being integer.
|
||||
// Naga requires them to be strictly unsigned, so we have to patch it.
|
||||
Some(crate::Binding::BuiltIn(built_in)) => {
|
||||
let scalar_kind = ty_inner.scalar_kind();
|
||||
let needs_uint = match built_in {
|
||||
let needs_inner_uint = match built_in {
|
||||
crate::BuiltIn::BaseInstance
|
||||
| crate::BuiltIn::BaseVertex
|
||||
| crate::BuiltIn::InstanceIndex
|
||||
| crate::BuiltIn::SampleIndex
|
||||
| crate::BuiltIn::VertexIndex => true,
|
||||
_ => false,
|
||||
| crate::BuiltIn::VertexIndex
|
||||
| crate::BuiltIn::LocalInvocationIndex => Some(crate::TypeInner::Scalar {
|
||||
kind: crate::ScalarKind::Uint,
|
||||
width: 4,
|
||||
}),
|
||||
crate::BuiltIn::GlobalInvocationId
|
||||
| crate::BuiltIn::LocalInvocationId
|
||||
| crate::BuiltIn::WorkGroupId
|
||||
| crate::BuiltIn::WorkGroupSize => Some(crate::TypeInner::Vector {
|
||||
size: crate::VectorSize::Tri,
|
||||
kind: crate::ScalarKind::Uint,
|
||||
width: 4,
|
||||
}),
|
||||
_ => None,
|
||||
};
|
||||
if needs_uint && scalar_kind == Some(crate::ScalarKind::Sint) {
|
||||
log::warn!("Treating {:?} as unsigned", built_in);
|
||||
module.types.fetch_or_append(crate::Type {
|
||||
name: None,
|
||||
inner: crate::TypeInner::Scalar {
|
||||
kind: crate::ScalarKind::Uint,
|
||||
width: 4,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
lookup_type.handle
|
||||
match (needs_inner_uint, ty_inner.scalar_kind()) {
|
||||
(Some(inner), Some(crate::ScalarKind::Sint)) => {
|
||||
log::warn!("Treating {:?} as unsigned", built_in);
|
||||
module
|
||||
.types
|
||||
.fetch_or_append(crate::Type { name: None, inner })
|
||||
}
|
||||
_ => lookup_type.handle,
|
||||
}
|
||||
}
|
||||
_ => lookup_type.handle,
|
||||
|
||||
Reference in new issue
Block a user