Rename DispatchAxis to DefaultThreadGroupSizes
このコミットが含まれているのは:
1 親
cecc16a52e
コミット
be0f0cf593
66ファイル変更
+216
-213
検索条件に一致するファイルはありません
@@ -46,24 +46,24 @@ partial class ComputeShaderDescriptorGenerator
|
||||
// Check for a dispatch axis argument first
|
||||
if (attribute.ConstructorArguments.Length == 1)
|
||||
{
|
||||
int dispatchAxis = (int)attribute.ConstructorArguments[0].Value!;
|
||||
int defaultSize = (int)attribute.ConstructorArguments[0].Value!;
|
||||
|
||||
(threadsX, threadsY, threadsZ) = (DispatchAxis)dispatchAxis switch
|
||||
(threadsX, threadsY, threadsZ) = (DefaultThreadGroupSizes)defaultSize 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),
|
||||
DefaultThreadGroupSizes.X => (64, 1, 1),
|
||||
DefaultThreadGroupSizes.Y => (1, 64, 1),
|
||||
DefaultThreadGroupSizes.Z => (1, 1, 64),
|
||||
DefaultThreadGroupSizes.XY => (8, 8, 1),
|
||||
DefaultThreadGroupSizes.XZ => (8, 1, 8),
|
||||
DefaultThreadGroupSizes.YZ => (1, 8, 8),
|
||||
DefaultThreadGroupSizes.XYZ => (4, 4, 4),
|
||||
_ => (0, 0, 0)
|
||||
};
|
||||
|
||||
// Validate the dispatch axis argument
|
||||
if ((threadsX, threadsY, threadsZ) is (0, 0, 0))
|
||||
{
|
||||
diagnostics.Add(InvalidThreadGroupSizeAttributeDefaultThreadGroupSize, structDeclarationSymbol, structDeclarationSymbol);
|
||||
diagnostics.Add(InvalidThreadGroupSizeAttributeDefaultThreadGroupSizes, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
threadsX = threadsY = threadsZ = 0;
|
||||
isCompilationEnabled = false;
|
||||
|
||||
@@ -60,9 +60,9 @@
|
||||
|
||||
<!-- ComputeSharp APIs -->
|
||||
<Compile Include="..\ComputeSharp\Core\Attributes\Enums\CompileOptions.cs" Link="ComputeSharp\Core\Attributes\Enums\CompileOptions.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Attributes\Enums\DefaultThreadGroupSizes.cs" Link="ComputeSharp\Core\Attributes\Enums\DefaultThreadGroupSizes.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" />
|
||||
<Compile Include="..\ComputeSharp\Core\Dispatch\GroupIds.cs" Link="ComputeSharp\Core\Dispatch\GroupIds.cs" />
|
||||
|
||||
@@ -654,19 +654,19 @@ partial class DiagnosticDescriptors
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an embedded bytecode shader with an invalid dispatch axis value.
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for shaders shader with an invalid DefaultThreadGroupSizes value.
|
||||
/// <para>
|
||||
/// Format: <c>"The shader of type {0} is using an invalid DefaultThreadGroupSize value in its [ThreadGroupSize] attribute"</c>.
|
||||
/// Format: <c>"The shader of type {0} is using an invalid DefaultThreadGroupSizes value in its [ThreadGroupSize] attribute"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidThreadGroupSizeAttributeDefaultThreadGroupSize = new(
|
||||
public static readonly DiagnosticDescriptor InvalidThreadGroupSizeAttributeDefaultThreadGroupSizes = new(
|
||||
id: "CMPS0048",
|
||||
title: "Invalid DefaultThreadGroupSize value for [ThreadGroupSize] use",
|
||||
messageFormat: "The shader of type {0} is using an invalid DefaultThreadGroupSize value in its [ThreadGroupSize] attribute",
|
||||
title: "Invalid DefaultThreadGroupSizes value for [ThreadGroupSize] use",
|
||||
messageFormat: "The shader of type {0} is using an invalid DefaultThreadGroupSizes value in its [ThreadGroupSize] attribute",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "The DefaultThreadGroupSize value for [ThreadGroupSize] attributes have to be valid.",
|
||||
description: "The DefaultThreadGroupSizes value for [ThreadGroupSize] attributes have to be valid.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
|
||||
/// <summary>
|
||||
|
||||
+12
-9
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="enum"/> to be used with <see cref="ThreadGroupSizeAttribute"/> to indicate the dispatch axis to precompile a shader for.
|
||||
/// A <see langword="enum"/> to be used with <see cref="ThreadGroupSizeAttribute"/> to more easily set default values for the thread group size.
|
||||
/// </summary>
|
||||
public enum DispatchAxis
|
||||
[Flags]
|
||||
public enum DefaultThreadGroupSizes
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates a shader dispatch only along the X axis.
|
||||
@@ -11,7 +14,7 @@ public enum DispatchAxis
|
||||
/// <remarks>
|
||||
/// This applies to using <see cref="GraphicsDeviceExtensions.For{T}(GraphicsDevice, int, in T)"/> or <see cref="ComputeContextExtensions.For{T}(in ComputeContext, int, in T)"/>.
|
||||
/// </remarks>
|
||||
X,
|
||||
X = 1 << 0,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a shader dispatch only along the Y axis.
|
||||
@@ -20,7 +23,7 @@ public enum DispatchAxis
|
||||
/// This applies to using <see cref="GraphicsDeviceExtensions.For{T}(GraphicsDevice, int, int, int, in T)"/> or <see cref="ComputeContextExtensions.For{T}(in ComputeContext, int, int, int, in T)"/>,
|
||||
/// but only as long as the input dispatch size on both the X and Z axes is <c>1</c>. Using any other combination will not be able to leverage the precompiled shader bytecode.
|
||||
/// </remarks>
|
||||
Y,
|
||||
Y = 1 << 1,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a shader dispatch only along the Z axis.
|
||||
@@ -29,7 +32,7 @@ public enum DispatchAxis
|
||||
/// This applies to using <see cref="GraphicsDeviceExtensions.For{T}(GraphicsDevice, int, int, int, in T)"/> or <see cref="ComputeContextExtensions.For{T}(in ComputeContext, int, int, int, in T)"/>,
|
||||
/// but only as long as the input dispatch size on both the X and Y axes is <c>1</c>. Using any other combination will not be able to leverage the precompiled shader bytecode.
|
||||
/// </remarks>
|
||||
Z,
|
||||
Z = 1 << 2,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a shader dispatch along the X and Y axes.
|
||||
@@ -39,7 +42,7 @@ public enum DispatchAxis
|
||||
/// <see cref="GraphicsDeviceExtensions.ForEach{T, TPixel}(GraphicsDevice, IReadWriteNormalizedTexture2D{TPixel}, in T)"/>, <see cref="ComputeContextExtensions.For{T}(in ComputeContext, int, int, in T)"/>,
|
||||
/// <see cref="ComputeContextExtensions.ForEach{T, TPixel}(in ComputeContext, IReadWriteNormalizedTexture2D{TPixel})"/> or <see cref="ComputeContextExtensions.ForEach{T, TPixel}(in ComputeContext, IReadWriteNormalizedTexture2D{TPixel}, in T)"/>.
|
||||
/// </remarks>
|
||||
XY,
|
||||
XY = X | Y,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a shader dispatch along the X and Z axes.
|
||||
@@ -48,7 +51,7 @@ public enum DispatchAxis
|
||||
/// This applies to using <see cref="GraphicsDeviceExtensions.For{T}(GraphicsDevice, int, int, int, in T)"/> or <see cref="ComputeContextExtensions.For{T}(in ComputeContext, int, int, int, in T)"/>,
|
||||
/// but only as long as the input dispatch size on the Y axis <c>1</c>. Using any other combination will not be able to leverage the precompiled shader bytecode.
|
||||
/// </remarks>
|
||||
XZ,
|
||||
XZ = X | Z,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a shader dispatch along the Y and Z axes.
|
||||
@@ -57,7 +60,7 @@ public enum DispatchAxis
|
||||
/// This applies to using <see cref="GraphicsDeviceExtensions.For{T}(GraphicsDevice, int, int, int, in T)"/> or <see cref="ComputeContextExtensions.For{T}(in ComputeContext, int, int, int, in T)"/>,
|
||||
/// but only as long as the input dispatch size on the X axis <c>1</c>. Using any other combination will not be able to leverage the precompiled shader bytecode.
|
||||
/// </remarks>
|
||||
YZ,
|
||||
YZ = Y | Z,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates a shader dispatch along the X, Y and Z axes.
|
||||
@@ -65,5 +68,5 @@ public enum DispatchAxis
|
||||
/// <remarks>
|
||||
/// This applies to using <see cref="GraphicsDeviceExtensions.For{T}(GraphicsDevice, int, int, int, in T)"/> or <see cref="ComputeContextExtensions.For{T}(in ComputeContext, int, int, int, in T)"/>.
|
||||
/// </remarks>
|
||||
XYZ
|
||||
XYZ = X | Y | Z
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace ComputeSharp;
|
||||
/// This attribute can be used to annotate shader types as follows:
|
||||
/// <code>
|
||||
/// // A compute shader that is dispatched on a target buffer
|
||||
/// [ThreadGroupSize(DispatchAxis.X)]
|
||||
/// [ThreadGroupSize(DefaultThreadGroupSizes.X)]
|
||||
/// struct MyShader : IComputeShader
|
||||
/// {
|
||||
/// }
|
||||
@@ -16,14 +16,14 @@ namespace ComputeSharp;
|
||||
/// Or similarly, for a pixel-like compute shader:
|
||||
/// <code>
|
||||
/// // A compute shader that is dispatched on a target texture
|
||||
/// [ThreadGroupSize(DispatchAxis.XY)]
|
||||
/// [ThreadGroupSize(DefaultThreadGroupSizes.XY)]
|
||||
/// struct MyShader : IComputeShader<float4>
|
||||
/// {
|
||||
/// }
|
||||
/// </code>
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Using <see cref="DispatchAxis"/> is an easier way to precompile shaders when dispatching them over known dimensions. For more
|
||||
/// Using <see cref="DefaultThreadGroupSizes"/> 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="ThreadGroupSizeAttribute(int, int, int)"/>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
@@ -33,20 +33,20 @@ public sealed class ThreadGroupSizeAttribute : Attribute
|
||||
/// <summary>
|
||||
/// 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 ThreadGroupSizeAttribute(DispatchAxis dispatchAxis)
|
||||
/// <param name="size">The default thread group size to use.</param>
|
||||
public ThreadGroupSizeAttribute(DefaultThreadGroupSizes size)
|
||||
{
|
||||
#if !SOURCE_GENERATOR
|
||||
(ThreadsX, ThreadsY, ThreadsZ) = dispatchAxis switch
|
||||
(ThreadsX, ThreadsY, ThreadsZ) = size 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),
|
||||
_ => default(ArgumentException).Throw<(int, int, int)>(nameof(dispatchAxis))
|
||||
DefaultThreadGroupSizes.X => (64, 1, 1),
|
||||
DefaultThreadGroupSizes.Y => (1, 64, 1),
|
||||
DefaultThreadGroupSizes.Z => (1, 1, 64),
|
||||
DefaultThreadGroupSizes.XY => (8, 8, 1),
|
||||
DefaultThreadGroupSizes.XZ => (8, 1, 8),
|
||||
DefaultThreadGroupSizes.YZ => (1, 8, 8),
|
||||
DefaultThreadGroupSizes.XYZ => (4, 4, 4),
|
||||
_ => default(ArgumentException).Throw<(int, int, int)>(nameof(size))
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする