[hlsl-out] basic support for pointer arguments

This commit is contained in:
Dzmitry Malyshau 2021-08-13 00:28:33 -04:00 committed by Dzmitry Malyshau
parent 1907a92928
commit e59582469c

View File

@ -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)];