Move and rename the HlslSourceHelper type

このコミットが含まれているのは:
Sergio Pedri committed 2023-12-21 18:40:13 +01:00
1 親 2f6ab50b9e
コミット a926a1211f
4ファイル変更
+25 -24

検索条件に一致するファイルはありません

+10 -10
ファイルの表示
@@ -451,13 +451,13 @@ partial class D2DPixelShaderDescriptorGenerator
/// <summary>
/// Produces the series of statements to build the current HLSL source.
/// </summary>
/// <param name="definedConstants"><inheritdoc cref="HlslSourceHelper.WriteTopDeclarations" path="/param[@name='definedConstants']/node()"/></param>
/// <param name="valueFields"><inheritdoc cref="HlslSourceHelper.WriteCapturedFields" path="/param[@name='valueFields']/node()"/></param>
/// <param name="definedConstants"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteTopDeclarations" path="/param[@name='definedConstants']/node()"/></param>
/// <param name="valueFields"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteCapturedFields" path="/param[@name='valueFields']/node()"/></param>
/// <param name="resourceTextureFields">The sequence of captured resource textures for the current shader.</param>
/// <param name="staticFields"><inheritdoc cref="HlslSourceHelper.WriteTopDeclarations" path="/param[@name='staticFields']/node()"/></param>
/// <param name="processedMethods"><inheritdoc cref="HlslSourceHelper.WriteTopDeclarations" path="/param[@name='processedMethods']/node()"/></param>
/// <param name="typeDeclarations"><inheritdoc cref="HlslSourceHelper.WriteTopDeclarations" path="/param[@name='typeDeclarations']/node()"/></param>
/// <param name="typeMethodDeclarations"><inheritdoc cref="HlslSourceHelper.WriteMethodDeclarations" path="/param[@name='typeMethodDeclarations']/node()"/></param>
/// <param name="staticFields"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteTopDeclarations" path="/param[@name='staticFields']/node()"/></param>
/// <param name="processedMethods"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteTopDeclarations" path="/param[@name='processedMethods']/node()"/></param>
/// <param name="typeDeclarations"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteTopDeclarations" path="/param[@name='typeDeclarations']/node()"/></param>
/// <param name="typeMethodDeclarations"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteMethodDeclarations" path="/param[@name='typeMethodDeclarations']/node()"/></param>
/// <param name="executeMethod">The body of the entry point of the shader.</param>
/// <param name="inputCount">The number of shader inputs to declare.</param>
/// <param name="inputSimpleIndices">The indicess of the simple shader inputs.</param>
@@ -480,7 +480,7 @@ partial class D2DPixelShaderDescriptorGenerator
{
using IndentedTextWriter writer = new();
HlslSourceHelper.WriteHeader(writer);
HlslSourceSyntaxProcessor.WriteHeader(writer);
// Shader metadata
writer.WriteLine($"#define D2D_INPUT_COUNT {inputCount}");
@@ -503,7 +503,7 @@ partial class D2DPixelShaderDescriptorGenerator
writer.WriteLine();
// The FXC compiler does not support type forward declarations
HlslSourceHelper.WriteTopDeclarations(
HlslSourceSyntaxProcessor.WriteTopDeclarations(
writer,
definedConstants,
staticFields,
@@ -511,7 +511,7 @@ partial class D2DPixelShaderDescriptorGenerator
typeDeclarations,
includeTypeForwardDeclarations: false);
HlslSourceHelper.WriteCapturedFields(writer, valueFields);
HlslSourceSyntaxProcessor.WriteCapturedFields(writer, valueFields);
// Resource textures
foreach (HlslResourceTextureField field in resourceTextureFields)
@@ -521,7 +521,7 @@ partial class D2DPixelShaderDescriptorGenerator
writer.WriteLine($"SamplerState __sampler__{field.Name} : register(s{field.Index});");
}
HlslSourceHelper.WriteMethodDeclarations(writer, processedMethods, typeMethodDeclarations);
HlslSourceSyntaxProcessor.WriteMethodDeclarations(writer, processedMethods, typeMethodDeclarations);
// Entry point
writer.WriteLine(executeMethod);
+1 -1
ファイルの表示
@@ -31,7 +31,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Models\TypeAliases.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SyntaxProcessors\HlslBytecodeSyntaxProcessor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SyntaxProcessors\ConstantBufferSyntaxProcessor.Generation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\HlslSourceHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SyntaxProcessors\HlslSourceSyntaxProcessor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SyntaxProcessors\HlslDefinitionsSyntaxProcessor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SyntaxRewriters\HlslSourceRewriter.Tracking.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SyntaxRewriters\HlslSourceRewriter.cs" />
@@ -1,11 +1,12 @@
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.SourceGeneration.SyntaxProcessors;
/// <summary>
/// A helper type to write HLSL source.
/// A processor responsible for formatting shared HLSL source for all shader types.
/// </summary>
internal static class HlslSourceHelper
internal static class HlslSourceSyntaxProcessor
{
/// <summary>
/// Writes the header included at the top of each generated HLSL shader.
+10 -10
ファイルの表示
@@ -489,14 +489,14 @@ partial class ComputeShaderDescriptorGenerator
/// <param name="threadsX">The thread ids value for the X axis.</param>
/// <param name="threadsY">The thread ids value for the Y axis.</param>
/// <param name="threadsZ">The thread ids value for the Z axis.</param>
/// <param name="definedConstants"><inheritdoc cref="HlslSourceHelper.WriteTopDeclarations" path="/param[@name='definedConstants']/node()"/></param>
/// <param name="definedConstants"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteTopDeclarations" path="/param[@name='definedConstants']/node()"/></param>
/// <param name="resourceFields">The sequence of resource instance fields for the current shader.</param>
/// <param name="valueFields"><inheritdoc cref="HlslSourceHelper.WriteCapturedFields" path="/param[@name='valueFields']/node()"/></param>
/// <param name="staticFields"><inheritdoc cref="HlslSourceHelper.WriteTopDeclarations" path="/param[@name='staticFields']/node()"/></param>
/// <param name="valueFields"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteCapturedFields" path="/param[@name='valueFields']/node()"/></param>
/// <param name="staticFields"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteTopDeclarations" path="/param[@name='staticFields']/node()"/></param>
/// <param name="sharedBuffers">The sequence of shared buffers declared by the shader.</param>
/// <param name="processedMethods"><inheritdoc cref="HlslSourceHelper.WriteTopDeclarations" path="/param[@name='processedMethods']/node()"/></param>
/// <param name="typeDeclarations"><inheritdoc cref="HlslSourceHelper.WriteTopDeclarations" path="/param[@name='typeDeclarations']/node()"/></param>
/// <param name="typeMethodDeclarations"><inheritdoc cref="HlslSourceHelper.WriteMethodDeclarations" path="/param[@name='typeMethodDeclarations']/node()"/></param>
/// <param name="processedMethods"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteTopDeclarations" path="/param[@name='processedMethods']/node()"/></param>
/// <param name="typeDeclarations"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteTopDeclarations" path="/param[@name='typeDeclarations']/node()"/></param>
/// <param name="typeMethodDeclarations"><inheritdoc cref="HlslSourceSyntaxProcessor.WriteMethodDeclarations" path="/param[@name='typeMethodDeclarations']/node()"/></param>
/// <param name="isComputeShader">Whether or not the current shader type is a compute shader.</param>
/// <param name="implicitTextureType">The type of the implicit target texture, if present.</param>
/// <param name="isSamplerUsed">Whether the static sampler is used by the shader.</param>
@@ -521,14 +521,14 @@ partial class ComputeShaderDescriptorGenerator
{
using IndentedTextWriter writer = new();
HlslSourceHelper.WriteHeader(writer);
HlslSourceSyntaxProcessor.WriteHeader(writer);
// Group size constants
writer.WriteLine($"#define __GroupSize__get_X {threadsX}");
writer.WriteLine($"#define __GroupSize__get_Y {threadsY}");
writer.WriteLine($"#define __GroupSize__get_Z {threadsZ}");
HlslSourceHelper.WriteTopDeclarations(
HlslSourceSyntaxProcessor.WriteTopDeclarations(
writer,
definedConstants,
staticFields,
@@ -545,7 +545,7 @@ partial class ComputeShaderDescriptorGenerator
writer.WriteLine("uint __y;");
writer.WriteLineIf(isComputeShader, "uint __z;");
HlslSourceHelper.WriteCapturedFields(writer, valueFields);
HlslSourceSyntaxProcessor.WriteCapturedFields(writer, valueFields);
}
int constantBuffersCount = 1;
@@ -593,7 +593,7 @@ partial class ComputeShaderDescriptorGenerator
writer.WriteLine($"groupshared {buffer.Type} {buffer.Name} [{count}];");
}
HlslSourceHelper.WriteMethodDeclarations(writer, processedMethods, typeMethodDeclarations);
HlslSourceSyntaxProcessor.WriteMethodDeclarations(writer, processedMethods, typeMethodDeclarations);
// Entry point
writer.WriteLine("[NumThreads(__GroupSize__get_X, __GroupSize__get_Y, __GroupSize__get_Z)]");