From c74e0a0a075887f1ef13537c6a15f7b112b33ec6 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 17 Aug 2019 10:31:41 +0200 Subject: [PATCH] Removed mustache code for single variable buffers --- .../Renderer/Models/Fields/ConstantBufferFieldInfo.cs | 11 +---------- .../Renderer/Templates/ShaderTemplate.mustache | 6 +++--- src/ComputeSharp.Shaders/Translation/ShaderLoader.cs | 2 +- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs index cb87c67d..5dff2be0 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs @@ -12,21 +12,12 @@ namespace ComputeSharp.Shaders.Renderer.Models.Fields /// public bool IsConstantBuffer { get; } = true; - /// - /// Gets whether or not this constant buffer actually contains a single, explicit variable - /// - public bool IsSingleValue { get; } - /// /// Creates a new instance with the specified parameters /// /// The type of the current field /// The name of the current field /// The index of the current constant buffer field - /// Whether or not this constant buffer actually contains a single, explicit variable - public ConstantBufferFieldInfo(string fieldType, string fieldName, int bufferIndex, bool singleValue) : base(fieldType, fieldName, bufferIndex) - { - IsSingleValue = singleValue; - } + public ConstantBufferFieldInfo(string fieldType, string fieldName, int bufferIndex) : base(fieldType, fieldName, bufferIndex) { } } } diff --git a/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache b/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache index 735850a5..1c2c1f94 100644 --- a/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache +++ b/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache @@ -3,7 +3,7 @@ {{#IsConstantBuffer}} cbuffer {{FieldName}}Buffer : register(b{{BufferIndex}}) { - {{&FieldType}} {{FieldName}}{{^IsSingleValue}}[2]{{/IsSingleValue}}; + {{&FieldType}} {{FieldName}}[2]; } {{/IsConstantBuffer}} {{!Readonly buffer}} @@ -16,8 +16,8 @@ cbuffer {{FieldName}}Buffer : register(b{{BufferIndex}}) {{/IsReadWriteBuffer}} {{/FieldsList}} -{{!Threads XYZ targets buffer}} -cbuffer __XYZ___Buffer : register(b{{ThreadsXYZConstantBufferIndex}}) +{{!Captured variables buffer}} +cbuffer __Variables__Buffer : register(b{{ThreadsXYZConstantBufferIndex}}) { uint __x__; uint __y__; diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs index 75cd3cbc..1cb1d820 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs @@ -142,7 +142,7 @@ namespace ComputeSharp.Shaders.Translation _Buffers.Add((descriptorRanges.Count - 1, (GraphicsResource)fieldValue)); string typeName = HlslKnownTypes.GetMappedName(fieldType.GenericTypeArguments[0]); - _BuffersList.Add(new ConstantBufferFieldInfo(typeName, fieldName, ConstantBuffersCount++, false)); + _BuffersList.Add(new ConstantBufferFieldInfo(typeName, fieldName, ConstantBuffersCount++)); } else if (HlslKnownTypes.IsReadOnlyBufferType(fieldType)) {