Rename [EmbeddedBytecode] to [ThreadGroupSize]
このコミットが含まれているのは:
1 親
2a7ddf0016
コミット
cecc16a52e
69ファイル変更
+235
-251
検索条件に一致するファイルはありません
@@ -16,9 +16,9 @@ public sealed class MissingComputeShaderDescriptorOnComputeShaderCodeFixer : Mis
|
||||
/// <summary>
|
||||
/// The set of type names for all attributes that can be over shader types.
|
||||
/// </summary>
|
||||
private static readonly string[] D2DAttributeTypeNames =
|
||||
private static readonly string[] AttributeTypeNames =
|
||||
[
|
||||
"ComputeSharp.EmbeddedBytecodeAttribute",
|
||||
"ComputeSharp.ThreadGroupSizeAttribute",
|
||||
"ComputeSharp.GroupSharedAttribute"
|
||||
];
|
||||
|
||||
@@ -30,7 +30,7 @@ public sealed class MissingComputeShaderDescriptorOnComputeShaderCodeFixer : Mis
|
||||
diagnosticId: MissingComputeShaderDescriptorOnComputeShaderTypeId,
|
||||
codeActionTitle: "Add [GeneratedComputeShaderDescriptor] attribute",
|
||||
attributeFullyQualifiedMetadataName: "ComputeSharp.GeneratedComputeShaderDescriptorAttribute",
|
||||
leadingAttributeFullyQualifiedMetadataNames: D2DAttributeTypeNames)
|
||||
leadingAttributeFullyQualifiedMetadataNames: AttributeTypeNames)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -106,14 +106,14 @@ partial class ComputeShaderDescriptorGenerator
|
||||
if (info is HlslBytecodeInfo.Win32Error win32Error)
|
||||
{
|
||||
diagnostic = DiagnosticInfo.Create(
|
||||
EmbeddedBytecodeFailedWithWin32Exception,
|
||||
HlslBytecodeFailedWithWin32Exception,
|
||||
structDeclarationSymbol,
|
||||
[structDeclarationSymbol, win32Error.HResult, win32Error.Message]);
|
||||
}
|
||||
else if (info is HlslBytecodeInfo.CompilerError dxcError)
|
||||
{
|
||||
diagnostic = DiagnosticInfo.Create(
|
||||
EmbeddedBytecodeFailedWithDxcCompilationException,
|
||||
HlslBytecodeFailedWithDxcCompilationException,
|
||||
structDeclarationSymbol,
|
||||
[structDeclarationSymbol, dxcError.Message]);
|
||||
}
|
||||
|
||||
@@ -33,10 +33,9 @@ partial class ComputeShaderDescriptorGenerator
|
||||
out bool isCompilationEnabled)
|
||||
{
|
||||
// Try to get the attribute that controls shader precompilation (this is always required)
|
||||
if (!structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName(typeof(EmbeddedBytecodeAttribute).FullName, out AttributeData? attribute))
|
||||
if (!structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName(typeof(ThreadGroupSizeAttribute).FullName, out AttributeData? attribute))
|
||||
{
|
||||
// Emit the diagnostics if dynamic shaders are not supported
|
||||
diagnostics.Add(MissingEmbeddedBytecodeAttributeWhenDynamicShaderCompilationIsNotSupported, structDeclarationSymbol, structDeclarationSymbol);
|
||||
diagnostics.Add(MissingThreadGroupSizeAttribute, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
threadsX = threadsY = threadsZ = 0;
|
||||
isCompilationEnabled = false;
|
||||
@@ -64,7 +63,7 @@ partial class ComputeShaderDescriptorGenerator
|
||||
// Validate the dispatch axis argument
|
||||
if ((threadsX, threadsY, threadsZ) is (0, 0, 0))
|
||||
{
|
||||
diagnostics.Add(InvalidEmbeddedBytecodeDispatchAxis, structDeclarationSymbol, structDeclarationSymbol);
|
||||
diagnostics.Add(InvalidThreadGroupSizeAttributeDefaultThreadGroupSize, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
threadsX = threadsY = threadsZ = 0;
|
||||
isCompilationEnabled = false;
|
||||
@@ -84,7 +83,7 @@ partial class ComputeShaderDescriptorGenerator
|
||||
explicitThreadsZ is < 1 or > 64)
|
||||
{
|
||||
// Failed to validate the thread number arguments
|
||||
diagnostics.Add(InvalidEmbeddedBytecodeThreadIds, structDeclarationSymbol, structDeclarationSymbol);
|
||||
diagnostics.Add(InvalidThreadGroupSizeAttributeValues, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
threadsX = threadsY = threadsZ = 0;
|
||||
isCompilationEnabled = false;
|
||||
|
||||
@@ -59,9 +59,9 @@
|
||||
<Compile Include="..\ComputeSharp.Core\Primitives\MatrixIndex.cs" Link="ComputeSharp.Core\Primitives\MatrixIndex.cs" />
|
||||
|
||||
<!-- ComputeSharp APIs -->
|
||||
<Compile Include="..\ComputeSharp\Core\Attributes\EmbeddedBytecodeAttribute.cs" Link="ComputeSharp\Core\Attributes\EmbeddedBytecodeAttribute.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Attributes\Enums\CompileOptions.cs" Link="ComputeSharp\Core\Attributes\Enums\CompileOptions.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Attributes\GroupSharedAttribute.cs" Link="ComputeSharp\Core\Attributes\GroupSharedAttribute.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Attributes\ThreadGroupSizeAttribute.cs" Link="ComputeSharp\Core\Attributes\ThreadGroupSizeAttribute.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Dispatch\DispatchAxis.cs" Link="ComputeSharp\Core\Dispatch\DispatchAxis.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Dispatch\DispatchSize.cs" Link="ComputeSharp\Core\Dispatch\DispatchSize.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Dispatch\GridIds.cs" Link="ComputeSharp\Core\Dispatch\GridIds.cs" />
|
||||
|
||||
@@ -590,83 +590,83 @@ partial class DiagnosticDescriptors
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an embedded bytecode shader with invalid thread ids values.
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for invalid thread group sizes.
|
||||
/// <para>
|
||||
/// Format: <c>"The shader of type {0} is annotated with invalid thread ids values"</c>.
|
||||
/// Format: <c>"The shader of type {0} is annotated with invalid [ThreadGroupSize] values"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidEmbeddedBytecodeThreadIds = new(
|
||||
public static readonly DiagnosticDescriptor InvalidThreadGroupSizeAttributeValues = new(
|
||||
id: "CMPS0044",
|
||||
title: "Invalid thread ids for shader with embedded bytecode",
|
||||
messageFormat: "The shader of type {0} is annotated with invalid thread ids values",
|
||||
title: "Invalid values for [ThreadGroupSize] attribute",
|
||||
messageFormat: "The shader of type {0} is annotated with invalid [ThreadGroupSize] values",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "The thread ids values for a shader marked as embedded bytecode have to be in the valid range.",
|
||||
description: "The thread group sizes for [ThreadGroupSize] have to be in the valid range.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an embedded bytecode shader failed due to a Win32 exception.
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for HLSL bytecode shader failed due to a Win32 exception.
|
||||
/// <para>
|
||||
/// Format: <c>"The shader of type {0} failed to compile due to a Win32 exception (HRESULT: {1:X8}, Message: "{2}")"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor EmbeddedBytecodeFailedWithWin32Exception = new(
|
||||
public static readonly DiagnosticDescriptor HlslBytecodeFailedWithWin32Exception = new(
|
||||
id: "CMPS0045",
|
||||
title: "Embedded bytecode compilation failed due to Win32 exception",
|
||||
title: "HLSL bytecode compilation failed due to Win32 exception",
|
||||
messageFormat: """The shader of type {0} failed to compile due to a Win32 exception (HRESULT: {1:X8}, Message: "{2}")""",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "The embedded bytecode for a shader failed to be compiled due to a Win32 exception.",
|
||||
description: "The HLSL bytecode for a shader failed to be compiled due to a Win32 exception.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an embedded bytecode shader failed due to an HLSL compilation exception.
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for HLSL bytecode shader failed due to an HLSL compilation exception.
|
||||
/// <para>
|
||||
/// Format: <c>"The shader of type {{0}} failed to compile due to an HLSL compiler error (Message: "{1}")"</c>.
|
||||
/// Format: <c>"The shader of type {0} failed to compile due to an HLSL compiler error (Message: "{1}")"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor EmbeddedBytecodeFailedWithDxcCompilationException = new(
|
||||
public static readonly DiagnosticDescriptor HlslBytecodeFailedWithDxcCompilationException = new(
|
||||
id: "CMPS0046",
|
||||
title: "Embedded bytecode compilation failed due to an HLSL compiler error",
|
||||
title: "HLSL bytecode compilation failed due to an HLSL compiler error",
|
||||
messageFormat: """The shader of type {0} failed to compile due to an HLSL compiler error (Message: "{1}")""",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "The embedded bytecode for a shader failed to be compiled due to an HLSL compiler error.",
|
||||
description: "The HLSL bytecode for a shader failed to be compiled due to an HLSL compiler error.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a shader without the embedded bytecode attribute,.
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a shader without the thread group size attribute.
|
||||
/// <para>
|
||||
/// Format: <c>"The shader of type {0} needs to be annotated as having embedded bytecode (using the [EmbeddedBytecode] attribute), as dynamic shader compilation is not supported"</c>.
|
||||
/// Format: <c>"The shader of type {0} needs to be annotated with [ThreadGroupSize], as dynamic shader compilation is not supported"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor MissingEmbeddedBytecodeAttributeWhenDynamicShaderCompilationIsNotSupported = new(
|
||||
public static readonly DiagnosticDescriptor MissingThreadGroupSizeAttribute = new(
|
||||
id: "CMPS0047",
|
||||
title: "Embedded bytecode compilation failed due to an HLSL compiler error",
|
||||
messageFormat: "The shader of type {0} needs to be annotated as having embedded bytecode (using the [EmbeddedBytecode] attribute), as dynamic shader compilation is not supported",
|
||||
title: "Missing [ThreadGroupSize] attribute on shader type",
|
||||
messageFormat: "The shader of type {0} needs to be annotated with [ThreadGroupSize] to be compiled at build time, as dynamic shader compilation is not supported",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "All shaders need to be annotated as having embedded bytecode (using the [EmbeddedBytecode] attribute).",
|
||||
description: "All shaders need to be annotated with the [ThreadGroupSize] attribute to be compiled at build time.",
|
||||
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>.
|
||||
/// Format: <c>"The shader of type {0} is using an invalid DefaultThreadGroupSize value in its [ThreadGroupSize] attribute"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidEmbeddedBytecodeDispatchAxis = new(
|
||||
public static readonly DiagnosticDescriptor InvalidThreadGroupSizeAttributeDefaultThreadGroupSize = 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",
|
||||
title: "Invalid DefaultThreadGroupSize value for [ThreadGroupSize] use",
|
||||
messageFormat: "The shader of type {0} is using an invalid DefaultThreadGroupSize value in its [ThreadGroupSize] attribute",
|
||||
category: "ComputeSharp.Shaders",
|
||||
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).",
|
||||
description: "The DefaultThreadGroupSize value for [ThreadGroupSize] attributes have to be valid.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
|
||||
+14
-29
@@ -3,21 +3,20 @@ using System;
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// An attribute that indicates that a given shader should be precompiled at build time and embedded
|
||||
/// directly into the containing assembly as static bytecode, to avoid compiling it at runtime.
|
||||
/// An attribute that indicates the size of the thread groups to use to dispatch a given compute shader.
|
||||
/// <para>
|
||||
/// This attribute can be used to annotate shader types as follows:
|
||||
/// <code>
|
||||
/// // A compute shader that is dispatched on a target buffer
|
||||
/// [EmbeddedBytecode(DispatchAxis.X)]
|
||||
/// [ThreadGroupSize(DispatchAxis.X)]
|
||||
/// struct MyShader : IComputeShader
|
||||
/// {
|
||||
/// }
|
||||
/// </code>
|
||||
/// Or similarly, for a pixel shader:
|
||||
/// Or similarly, for a pixel-like compute shader:
|
||||
/// <code>
|
||||
/// // A pixel shader that is dispatched on a target texture
|
||||
/// [EmbeddedBytecode(DispatchAxis.XY)]
|
||||
/// // A compute shader that is dispatched on a target texture
|
||||
/// [ThreadGroupSize(DispatchAxis.XY)]
|
||||
/// struct MyShader : IComputeShader<float4>
|
||||
/// {
|
||||
/// }
|
||||
@@ -25,31 +24,17 @@ namespace ComputeSharp;
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Using <see cref="DispatchAxis"/> is an easier way to precompile shaders when dispatching them over known dimensions. For more
|
||||
/// fine grained control over the thread size values when dispatching, use <see cref="EmbeddedBytecodeAttribute(int, int, int)"/>.
|
||||
/// fine grained control over the thread size values when dispatching, use <see cref="ThreadGroupSizeAttribute(int, int, int)"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// </para>
|
||||
/// The runtime compilation will automatically be skipped if the shader is invoked using matching thread count values,
|
||||
/// otherwise the usual runtime compilation will be used as fallback if the <c>ComputeSharp.Dxc</c> library is
|
||||
/// referenced. If not, <see cref="NotSupportedException"/> will be thrown when trying to dispatch the shader.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Using this attribute is mandatory when not referencing <c>ComputeSharp.Dxc</c>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This attribute can only be used when the shader type being annotated does not require dynamic
|
||||
/// features. Specifically, this attribute is not supported if the shader captures any delegates.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
|
||||
public sealed class EmbeddedBytecodeAttribute : Attribute
|
||||
public sealed class ThreadGroupSizeAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="EmbeddedBytecodeAttribute"/> instance with the specified parameters.
|
||||
/// Creates a new <see cref="ThreadGroupSizeAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="dispatchAxis">The target dispatch axes for the shader to run.</param>
|
||||
public EmbeddedBytecodeAttribute(DispatchAxis dispatchAxis)
|
||||
public ThreadGroupSizeAttribute(DispatchAxis dispatchAxis)
|
||||
{
|
||||
#if !SOURCE_GENERATOR
|
||||
(ThreadsX, ThreadsY, ThreadsZ) = dispatchAxis switch
|
||||
@@ -67,12 +52,12 @@ public sealed class EmbeddedBytecodeAttribute : Attribute
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="EmbeddedBytecodeAttribute"/> instance with the specified parameters.
|
||||
/// Creates a new <see cref="ThreadGroupSizeAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="threadsX">The number of threads in each thread group for the X axis.</param>
|
||||
/// <param name="threadsY">The number of threads in each thread group for the Y axis.</param>
|
||||
/// <param name="threadsZ">The number of threads in each thread group for the Z axis.</param>
|
||||
public EmbeddedBytecodeAttribute(int threadsX, int threadsY, int threadsZ)
|
||||
public ThreadGroupSizeAttribute(int threadsX, int threadsY, int threadsZ)
|
||||
{
|
||||
ThreadsX = threadsX;
|
||||
ThreadsY = threadsY;
|
||||
@@ -80,17 +65,17 @@ public sealed class EmbeddedBytecodeAttribute : Attribute
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of threads in each thread group for the X axis
|
||||
/// Gets the number of threads in each thread group for the X axis.
|
||||
/// </summary>
|
||||
public int ThreadsX { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of threads in each thread group for the Y axis
|
||||
/// Gets the number of threads in each thread group for the Y axis.
|
||||
/// </summary>
|
||||
public int ThreadsY { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of threads in each thread group for the Z axis
|
||||
/// Gets the number of threads in each thread group for the Z axis.
|
||||
/// </summary>
|
||||
public int ThreadsZ { get; }
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="enum"/> to be used with <see cref="EmbeddedBytecodeAttribute"/> to indicate the dispatch axis to precompile a shader for.
|
||||
/// A <see langword="enum"/> to be used with <see cref="ThreadGroupSizeAttribute"/> to indicate the dispatch axis to precompile a shader for.
|
||||
/// </summary>
|
||||
public enum DispatchAxis
|
||||
{
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする