From 88f2c9e08aeacde9d4a0d5ed9840e95b1df49f0d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 13 Feb 2021 14:46:06 +0100 Subject: [PATCH] Fixed incorrect HLSL generation with constant buffers --- src/ComputeSharp.Shaders/Renderer/HlslShaderRenderer.cs | 2 +- src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp.Shaders/Renderer/HlslShaderRenderer.cs b/src/ComputeSharp.Shaders/Renderer/HlslShaderRenderer.cs index e2bd3929..1232512f 100644 --- a/src/ComputeSharp.Shaders/Renderer/HlslShaderRenderer.cs +++ b/src/ComputeSharp.Shaders/Renderer/HlslShaderRenderer.cs @@ -96,7 +96,7 @@ namespace ComputeSharp.Shaders.Renderer builder.Append(buffer.FieldType); builder.Append(' '); builder.Append(buffer.FieldName); - builder.Append("[2];"); + builder.AppendLine("[2];"); builder.AppendLine('}'); break; diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.cs index b2cdd86d..a04b9b61 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.cs @@ -29,7 +29,11 @@ namespace ComputeSharp.Shaders.Translation /// /// The number of constant buffers to define in the shader. /// - private uint constantBuffersCount; + /// + /// This starts at 1 as there's always an initial constant buffer before user-defined ones, containing + /// the captured scalar and vector values as well as the iteration ranges for the shader dispatch. + /// + private uint constantBuffersCount = 1; /// /// The number of readonly buffers to define in the shader.