diff --git a/Makefile b/Makefile index b452a2397..268df6a6b 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index cc4b9cebb..bd085a84b 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -2690,26 +2690,34 @@ impl> Parser { // 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,