From 73cb6d4bdf3eb455717a17d7ec216d36f6f5b589 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 11 Jan 2021 09:20:38 -0500 Subject: [PATCH] [spv] Relax decoration checks for global variables --- src/front/spv/mod.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index d9fe103de6..d69b431d0c 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -2290,10 +2290,13 @@ impl> Parser { None }; let lookup_type = self.lookup_type.lookup(type_id)?; - let dec = self - .future_decor - .remove(&id) - .ok_or(Error::InvalidBinding(id))?; + let dec = match self.future_decor.remove(&id) { + Some(dec) => dec, + None => { + log::warn!("Missing decoration for global {:?}", id); + Decoration::default() + } + }; let class = { use spirv::StorageClass as Sc; @@ -2320,11 +2323,6 @@ impl> Parser { } }; - let binding = match (class, &module.types[lookup_type.handle].inner) { - (crate::StorageClass::Input, &crate::TypeInner::Struct { .. }) - | (crate::StorageClass::Output, &crate::TypeInner::Struct { .. }) => None, - _ => Some(dec.get_binding().ok_or(Error::InvalidBinding(id))?), - }; let is_storage = match module.types[lookup_type.handle].inner { crate::TypeInner::Struct { .. } => class == crate::StorageClass::Storage, crate::TypeInner::Image { @@ -2347,6 +2345,7 @@ impl> Parser { crate::StorageAccess::empty() }; + let binding = dec.get_binding(); let ty = match binding { // 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.