Enable source generator support for DispatchAxis
このコミットが含まれているのは:
1 親
74793ab9f0
コミット
3e7a3c5b7c
15ファイル変更
+75
-20
検索条件に一致するファイルはありません
@@ -8,7 +8,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct ColorfulInfinity : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct ContouredLayers : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct FourColorGradient : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct FractalTiling : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct HelloWorld : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct MengerJourney : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct Octagrams : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct ProteanClouds : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct PyramidPattern : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct TriangleGridContouring : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
#if SAMPLE_APP
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
#endif
|
||||
internal readonly partial struct TwoTiledTruchet : IPixelShader<float4>
|
||||
{
|
||||
|
||||
@@ -54,3 +54,4 @@ CMPS0044 | ComputeSharp.IComputeShader | Error | IShaderGenerator, [Documentatio
|
||||
CMPS0045 | ComputeSharp.IComputeShader | Error | IShaderGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0046 | ComputeSharp.IComputeShader | Error | IShaderGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0047 | ComputeSharp.IComputeShader | Error | IShaderGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0048 | ComputeSharp.IComputeShader | Error | IShaderGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
@@ -662,4 +662,20 @@ internal static class DiagnosticDescriptors
|
||||
isEnabledByDefault: true,
|
||||
description: "When dynamic shader compilation is not supported (ie. when ComputeSharp.Dynamic is not referenced), all shaders need to be annotated as having embedded bytecode (using the [EmbeddedBytecode] attribute).",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an embedded bytecode shader with an invalid dispatch axis value.
|
||||
/// <para>
|
||||
/// Format: <c>"The shader of type {0} is annotated with an invalid dispatch axis value"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidEmbeddedBytecodeDispatchAxis = new(
|
||||
id: "CMPS0048",
|
||||
title: "Invalid dispatch axis for shader with embedded bytecode",
|
||||
messageFormat: "The shader of type {0} is annotated with with an invalid dispatch axis value",
|
||||
category: typeof(IShaderGenerator).FullName,
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "The dispatch axis value for a shader marked as embedded bytecode have to be valid (flags are not supported).",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
}
|
||||
@@ -59,21 +59,59 @@ public sealed partial class IShaderGenerator
|
||||
return new(true, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Validate the thread number arguments
|
||||
if (attribute.ConstructorArguments.Length != 3 ||
|
||||
attribute.ConstructorArguments[0].Value is not int threadsX ||
|
||||
attribute.ConstructorArguments[1].Value is not int threadsY ||
|
||||
attribute.ConstructorArguments[2].Value is not int threadsZ ||
|
||||
threadsX is < 1 or > 1024 ||
|
||||
threadsY is < 1 or > 1024 ||
|
||||
threadsZ is < 1 or > 64)
|
||||
int threadsX;
|
||||
int threadsY;
|
||||
int threadsZ;
|
||||
|
||||
// Check for a dispatch axis argument first
|
||||
if (attribute.ConstructorArguments.Length == 1)
|
||||
{
|
||||
int dispatchAxis = (int)attribute.ConstructorArguments[0].Value!;
|
||||
|
||||
(threadsX, threadsY, threadsZ) = (DispatchAxis)dispatchAxis switch
|
||||
{
|
||||
DispatchAxis.X => (64, 1, 1),
|
||||
DispatchAxis.Y => (1, 64, 1),
|
||||
DispatchAxis.Z => (1, 1, 64),
|
||||
DispatchAxis.XY => (8, 8, 1),
|
||||
DispatchAxis.XZ => (8, 1, 8),
|
||||
DispatchAxis.YZ => (1, 8, 8),
|
||||
DispatchAxis.XYZ => (4, 4, 4),
|
||||
_ => (0, 0, 0)
|
||||
};
|
||||
|
||||
// Validate the dispatch axis argument
|
||||
if ((threadsX, threadsY, threadsZ) is (0, 0, 0))
|
||||
{
|
||||
builder.Add(InvalidEmbeddedBytecodeDispatchAxis, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
diagnostics = builder.ToImmutable();
|
||||
|
||||
return new(true, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
else if (
|
||||
attribute.ConstructorArguments.Length != 3 ||
|
||||
attribute.ConstructorArguments[0].Value is not int explicitThreadsX ||
|
||||
attribute.ConstructorArguments[1].Value is not int explicitThreadsY ||
|
||||
attribute.ConstructorArguments[2].Value is not int explicitThreadsZ ||
|
||||
explicitThreadsX is < 1 or > 1024 ||
|
||||
explicitThreadsY is < 1 or > 1024 ||
|
||||
explicitThreadsZ is < 1 or > 64)
|
||||
{
|
||||
// Failed to validate the thread number arguments
|
||||
builder.Add(InvalidEmbeddedBytecodeThreadIds, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
diagnostics = builder.ToImmutable();
|
||||
|
||||
return new(true, 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
threadsX = explicitThreadsX;
|
||||
threadsY = explicitThreadsY;
|
||||
threadsZ = explicitThreadsZ;
|
||||
}
|
||||
|
||||
// If the current shader is dynamic, emit a diagnostic error
|
||||
if (isDynamicShader)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする