diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Functions/ParameterInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Functions/ParameterInfo.cs
index dce851ef..2c6b4f5b 100644
--- a/src/ComputeSharp.Shaders/Renderer/Models/Functions/ParameterInfo.cs
+++ b/src/ComputeSharp.Shaders/Renderer/Models/Functions/ParameterInfo.cs
@@ -5,6 +5,11 @@
///
internal class ParameterInfo
{
+ ///
+ /// Gets the modifier to use for the current parameter
+ ///
+ public string ParameterModifier { get; }
+
///
/// Gets the type of the current parameter
///
@@ -23,11 +28,13 @@
///
/// Creates a new instance with the specified parameters
///
+ /// The modifier to use for the current parameter
/// The type of the current parameter
/// The name of the current parameter
/// Indicates whether or not the current parameter is the last one
- public ParameterInfo(string parameterType, string parameterName, bool last)
+ public ParameterInfo(string parameterModifier, string parameterType, string parameterName, bool last)
{
+ ParameterModifier = parameterModifier;
ParameterType = parameterType;
ParameterName = parameterName;
IsLastParameter = last;
diff --git a/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache b/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache
index 0e058d76..14c5d075 100644
--- a/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache
+++ b/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache
@@ -42,7 +42,7 @@ cbuffer _{{FieldName}} : register(b{{BufferIndex}})
{{!Shader private functions}}
{{#FunctionsList}}
// {{FunctionCsharpReturnType}} {{FunctionFullName}}({{FunctionCsharpParameters}})
-{{ReturnType}} {{FunctionName}}({{#ParametersList}}{{ParameterType}} {{ParameterName}}{{^IsLastParameter}}, {{/IsLastParameter}}{{/ParametersList}})
+{{ReturnType}} {{FunctionName}}({{#ParametersList}}{{ParameterModifier}} {{ParameterType}} {{ParameterName}}{{^IsLastParameter}}, {{/IsLastParameter}}{{/ParametersList}})
{{FunctionBody}}
{{/FunctionsList}}
diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs
index bec451e6..e0a547c3 100644
--- a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs
+++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs
@@ -13,6 +13,7 @@ using ComputeSharp.Shaders.Renderer.Models.Functions;
using ComputeSharp.Shaders.Translation.Enums;
using ComputeSharp.Shaders.Translation.Models;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Vortice.Direct3D12;
using ParameterInfo = ComputeSharp.Shaders.Renderer.Models.Functions.ParameterInfo;
@@ -311,10 +312,11 @@ namespace ComputeSharp.Shaders.Translation
// Get the function parameters
IReadOnlyList parameters = (
from parameter in root.ParameterList.Parameters.Select((p, i) => (Node: p, Index: i))
+ let modifier = parameter.Node.Modifiers.Any(token => token.IsKind(SyntaxKind.OutKeyword)) ? "out" : "in"
let type = parameter.Node.Type.ToFullString()
let parameterName = parameter.Node.Identifier.ToFullString()
let last = parameter.Index == root.ParameterList.Parameters.Count - 1
- select new ParameterInfo(type, parameterName, last)).ToArray();
+ select new ParameterInfo(modifier, type, parameterName, last)).ToArray();
// Get the function body
string body = root.Body.ToFullString();