From e59582469c586b99f025fa99508964d9026746b9 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 13 Aug 2021 00:28:33 -0400 Subject: [PATCH] [hlsl-out] basic support for pointer arguments --- src/back/hlsl/writer.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/back/hlsl/writer.rs b/src/back/hlsl/writer.rs index 5393b3eb7e..19aadd51fa 100644 --- a/src/back/hlsl/writer.rs +++ b/src/back/hlsl/writer.rs @@ -760,7 +760,16 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { back::FunctionType::Function(handle) => { for (index, arg) in func.arguments.iter().enumerate() { // Write argument type - self.write_type(module, arg.ty)?; + let arg_ty = match module.types[arg.ty].inner { + // pointers in function arguments are expected and resolve to `inout` + TypeInner::Pointer { base, .. } => { + //TODO: can we narrow this down to just `in` when possible? + write!(self.out, "inout ")?; + base + } + _ => arg.ty, + }; + self.write_type(module, arg_ty)?; let argument_name = &self.names[&NameKey::FunctionArgument(handle, index as u32)];