From 2b163dc2a17579cdabe43fb6dcced463ccaf6f0f Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 25 Mar 2021 23:49:30 -0400 Subject: [PATCH] [msl] fix pointer address spaces, private forwarding and initialization --- src/back/msl/writer.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/back/msl/writer.rs b/src/back/msl/writer.rs index 060f1a9cd2..c0d581693e 100644 --- a/src/back/msl/writer.rs +++ b/src/back/msl/writer.rs @@ -109,6 +109,7 @@ impl crate::StorageClass { match *self { crate::StorageClass::Uniform | crate::StorageClass::Storage + | crate::StorageClass::Private | crate::StorageClass::Handle => true, _ => false, } @@ -117,14 +118,15 @@ impl crate::StorageClass { fn get_name(&self, global_use: GlobalUse) -> Option<&'static str> { match *self { Self::Handle => None, - Self::Uniform => Some("constant"), + Self::Uniform | Self::PushConstant => Some("constant"), //TODO: should still be "constant" for read-only buffers Self::Storage => Some(if global_use.contains(GlobalUse::WRITE) { "device" } else { - "storage " + "storage" }), - Self::Private | Self::Function | Self::WorkGroup | Self::PushConstant => Some(""), + Self::Private | Self::Function => Some("thread"), + Self::WorkGroup => Some("threadgroup"), } } } @@ -1386,11 +1388,11 @@ impl Writer { }; write!(self.out, "{}", INDENT)?; tyvar.try_fmt(&mut self.out)?; - if let Some(value) = var.init { - let value_str = &self.names[&NameKey::Constant(value)]; - write!(self.out, " = {}", value_str)?; - } - writeln!(self.out, ";")?; + let value_str = match var.init { + Some(value) => &self.names[&NameKey::Constant(value)], + None => "{}", + }; + writeln!(self.out, " = {};", value_str)?; } // Now refactor the inputs in a way that the rest of the code expects