Merge pull request #620 from Sergio0694/dev/generated-descriptor-attribute
Add [GeneratedComputeShaderDescriptor] for D3D12 shaders
このコミットが含まれているのは:
82ファイル変更
+1274
-1029
検索条件に一致するファイルはありません
@@ -146,6 +146,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.D2D1.Tests.Sou
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Win32", "Win32", "{D991153C-A34D-4042-B76F-822ADB111DD0}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ComputeSharp.CodeFixing", "src\ComputeSharp.CodeFixing\ComputeSharp.CodeFixing.shproj", "{29F6E256-BA0E-4F3B-854E-50839D67C6DD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputeSharp.CodeFixers", "src\ComputeSharp.CodeFixers\ComputeSharp.CodeFixers.csproj", "{9B4448B1-200F-4966-8A13-A508691B3003}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -418,6 +422,14 @@ Global
|
||||
{59A17380-24A0-4BD7-9012-B105A9E7D46F}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{59A17380-24A0-4BD7-9012-B105A9E7D46F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{59A17380-24A0-4BD7-9012-B105A9E7D46F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{9B4448B1-200F-4966-8A13-A508691B3003}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{9B4448B1-200F-4966-8A13-A508691B3003}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{9B4448B1-200F-4966-8A13-A508691B3003}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{9B4448B1-200F-4966-8A13-A508691B3003}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{9B4448B1-200F-4966-8A13-A508691B3003}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{9B4448B1-200F-4966-8A13-A508691B3003}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{9B4448B1-200F-4966-8A13-A508691B3003}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{9B4448B1-200F-4966-8A13-A508691B3003}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -463,11 +475,14 @@ Global
|
||||
samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{0071701e-b9c5-4098-be5f-ef556c4553c6}*SharedItemsImports = 5
|
||||
samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{0800bd51-499d-44c2-9417-fd1f7fdfe9c4}*SharedItemsImports = 13
|
||||
samples\ComputeSharp.SwapChain.Shaders.D2D1.Shared\ComputeSharp.SwapChain.Shaders.D2D1.Shared.projitems*{209c95a3-fa53-431b-b688-3299ca6c29d2}*SharedItemsImports = 5
|
||||
src\ComputeSharp.CodeFixing\ComputeSharp.CodeFixing.projitems*{29f6e256-ba0e-4f3b-854e-50839d67c6dd}*SharedItemsImports = 13
|
||||
src\ComputeSharp.Win32.D2D1\ComputeSharp.Win32.D2D1.projitems*{4d7d9ba8-a821-4b1c-9ee2-cbcf5849906e}*SharedItemsImports = 5
|
||||
src\ComputeSharp.Win32.D3D12\ComputeSharp.Win32.D3D12.projitems*{514ff00e-bbf0-4d55-a47c-eeeb6208adce}*SharedItemsImports = 13
|
||||
src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{51d5a422-d3a5-4c4d-8a6d-a048940bf279}*SharedItemsImports = 13
|
||||
src\ComputeSharp.CodeFixing\ComputeSharp.CodeFixing.projitems*{54654960-54b5-4e19-b3ed-993591ca39e5}*SharedItemsImports = 5
|
||||
samples\ComputeSharp.SwapChain.Shaders.D2D1.Shared\ComputeSharp.SwapChain.Shaders.D2D1.Shared.projitems*{73c32d0f-64db-4674-84e9-8fcc41228474}*SharedItemsImports = 5
|
||||
src\ComputeSharp.SourceGeneration.Hlsl\ComputeSharp.SourceGeneration.Hlsl.projitems*{9ac496a3-bbf0-4c8f-a50d-a20bf01c5e05}*SharedItemsImports = 13
|
||||
src\ComputeSharp.CodeFixing\ComputeSharp.CodeFixing.projitems*{9b4448b1-200f-4966-8a13-a508691b3003}*SharedItemsImports = 5
|
||||
src\ComputeSharp.Win32.D2D1\ComputeSharp.Win32.D2D1.projitems*{9da1da9f-f8b2-4b25-be80-c21f773029e3}*SharedItemsImports = 13
|
||||
samples\ComputeSharp.SwapChain.Shaders.D2D1.Shared\ComputeSharp.SwapChain.Shaders.D2D1.Shared.projitems*{9ea5ae9d-c39a-4f43-b03e-0a848ea2558a}*SharedItemsImports = 5
|
||||
src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{a5997814-d8d2-4541-87ac-c3e53caa67c0}*SharedItemsImports = 13
|
||||
|
||||
@@ -82,6 +82,7 @@ internal static partial class BlasHelpers
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct FullyConnectedForwardKernel : IComputeShader
|
||||
{
|
||||
private readonly int n;
|
||||
|
||||
@@ -110,6 +110,7 @@ public partial class DispatchingBenchmark : IDisposable
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct TestShader : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
@@ -315,6 +315,7 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct VerticalConvolutionProcessor : IComputeShader
|
||||
{
|
||||
private readonly IReadWriteNormalizedTexture2D<float4> source;
|
||||
@@ -353,6 +354,7 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader
|
||||
{
|
||||
private readonly float z;
|
||||
@@ -393,6 +395,7 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct GammaHighlightProcessor : IComputeShader
|
||||
{
|
||||
private readonly IReadWriteNormalizedTexture2D<float4> source;
|
||||
@@ -418,6 +421,7 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct InverseGammaHighlightProcessor : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteTexture2D<float4> source;
|
||||
|
||||
@@ -119,6 +119,7 @@ public sealed partial class HlslGaussianBlurProcessor
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct VerticalConvolutionProcessor : IComputeShader
|
||||
{
|
||||
private readonly IReadWriteNormalizedTexture2D<float4> source;
|
||||
@@ -152,6 +153,7 @@ public sealed partial class HlslGaussianBlurProcessor
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct HorizontalConvolutionProcessor : IComputeShader
|
||||
{
|
||||
private readonly IReadWriteNormalizedTexture2D<float4> source;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace ComputeSharp.Sample.FSharp.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct MultiplyByTwo : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
@@ -25,6 +25,7 @@ Formatting.PrintMatrix(array, 10, 10, "AFTER");
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct MultiplyByTwo : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ColorfulInfinity : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ContouredLayers : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ExtrudedTruchetPattern : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct FourColorGradient : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct FractalTiling : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct HelloWorld : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct MengerJourney : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Octagrams : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ProteanClouds : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct PyramidPattern : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct TerracedHills : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct TriangleGridContouring : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct TwoTiledTruchet : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\ComputeSharp.CodeFixing\ComputeSharp.CodeFixing.projitems" Label="Shared" />
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Composition;
|
||||
using ComputeSharp.CodeFixing;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CodeFixes;
|
||||
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
|
||||
namespace ComputeSharp.D2D1.CodeFixers;
|
||||
|
||||
/// <summary>
|
||||
/// A code fixer that adds the <c>[GeneratedComputeShaderDescriptor]</c> to compute shader types with no descriptor.
|
||||
/// </summary>
|
||||
[ExportCodeFixProvider(LanguageNames.CSharp)]
|
||||
[Shared]
|
||||
public sealed class MissingComputeShaderDescriptorOnComputeShaderCodeFixer : MissingAttributeCodeFixer
|
||||
{
|
||||
/// <summary>
|
||||
/// The set of type names for all attributes that can be over shader types.
|
||||
/// </summary>
|
||||
private static readonly string[] D2DAttributeTypeNames = new[]
|
||||
{
|
||||
"ComputeSharp.EmbeddedBytecodeAttribute",
|
||||
"ComputeSharp.GroupSharedAttribute"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MissingAttributeCodeFixer"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
public MissingComputeShaderDescriptorOnComputeShaderCodeFixer()
|
||||
: base(
|
||||
diagnosticId: MissingComputeShaderDescriptorOnComputeShaderTypeId,
|
||||
codeActionTitle: "Add [GeneratedComputeShaderDescriptor] attribute",
|
||||
attributeFullyQualifiedMetadataName: "ComputeSharp.GeneratedComputeShaderDescriptorAttribute",
|
||||
leadingAttributeFullyQualifiedMetadataNames: D2DAttributeTypeNames)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>29f6e256-ba0e-4f3b-854e-50839d67c6dd</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>ComputeSharp.CodeFixing</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)MissingAttributeCodeFixer.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>29f6e256-ba0e-4f3b-854e-50839d67c6dd</ProjectGuid>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
||||
<PropertyGroup />
|
||||
<Import Project="ComputeSharp.CodeFixing.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,235 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CodeActions;
|
||||
using Microsoft.CodeAnalysis.CodeFixes;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Editing;
|
||||
using Microsoft.CodeAnalysis.Simplification;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
namespace ComputeSharp.CodeFixing;
|
||||
|
||||
/// <summary>
|
||||
/// A code fixer that adds an attribute that is missing on a type that requires it.
|
||||
/// </summary>
|
||||
public abstract class MissingAttributeCodeFixer : CodeFixProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The title to display for the code fixer.
|
||||
/// </summary>
|
||||
private readonly string codeActionTitle;
|
||||
|
||||
/// <summary>
|
||||
/// The fully qualified type name of the attribute to add.
|
||||
/// </summary>
|
||||
private readonly string attributeFullyQualifiedMetadataName;
|
||||
|
||||
/// <summary>
|
||||
/// The fully qualified type names of leading attributes to skip.
|
||||
/// </summary>
|
||||
private readonly IEnumerable<string> leadingAttributeFullyQualifiedMetadataNames;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MissingAttributeCodeFixer"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="diagnosticId">The diagnostic id to trigger the code fixer.</param>
|
||||
/// <param name="codeActionTitle">The title to display for the code fixer.</param>
|
||||
/// <param name="attributeFullyQualifiedMetadataName">The fully qualified type name of the attribute to add.</param>
|
||||
/// <param name="leadingAttributeFullyQualifiedMetadataNames">The fully qualified type names of leading attributes to skip.</param>
|
||||
protected MissingAttributeCodeFixer(
|
||||
string diagnosticId,
|
||||
string codeActionTitle,
|
||||
string attributeFullyQualifiedMetadataName,
|
||||
IEnumerable<string> leadingAttributeFullyQualifiedMetadataNames)
|
||||
{
|
||||
this.codeActionTitle = codeActionTitle;
|
||||
this.attributeFullyQualifiedMetadataName = attributeFullyQualifiedMetadataName;
|
||||
this.leadingAttributeFullyQualifiedMetadataNames = leadingAttributeFullyQualifiedMetadataNames;
|
||||
|
||||
FixableDiagnosticIds = ImmutableArray.Create(diagnosticId);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public sealed override ImmutableArray<string> FixableDiagnosticIds { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public sealed override Microsoft.CodeAnalysis.CodeFixes.FixAllProvider? GetFixAllProvider()
|
||||
{
|
||||
return new FixAllProvider(this);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
|
||||
{
|
||||
Diagnostic diagnostic = context.Diagnostics[0];
|
||||
TextSpan diagnosticSpan = context.Span;
|
||||
|
||||
SyntaxNode? root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Get the struct declaration from the target diagnostic
|
||||
if (root?.FindNode(diagnosticSpan) is StructDeclarationSyntax structDeclaration)
|
||||
{
|
||||
// Register the code fix to update the return type to be Task instead
|
||||
context.RegisterCodeFix(
|
||||
CodeAction.Create(
|
||||
title: this.codeActionTitle,
|
||||
createChangedDocument: token => AddMissingAttribute(context.Document, root, structDeclaration, token),
|
||||
equivalenceKey: this.codeActionTitle),
|
||||
diagnostic);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the code fix to add the missing attribute to a target type.
|
||||
/// </summary>
|
||||
/// <param name="document">The original document being fixed.</param>
|
||||
/// <param name="root">The original tree root belonging to the current document.</param>
|
||||
/// <param name="structDeclaration">The <see cref="StructDeclarationSyntax"/> to update.</param>
|
||||
/// <param name="cancellationToken">The cancellation token for the operation.</param>
|
||||
/// <returns>An updated document with the applied code fix, and the return type of the method being <see cref="Task"/>.</returns>
|
||||
private async Task<Document> AddMissingAttribute(
|
||||
Document document,
|
||||
SyntaxNode root,
|
||||
StructDeclarationSyntax structDeclaration,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
// Get the new struct declaration
|
||||
SyntaxNode updatedStructDeclaration = await AddMissingAttribute(
|
||||
document,
|
||||
structDeclaration,
|
||||
cancellationToken);
|
||||
|
||||
// Replace the node in the document tree
|
||||
return document.WithSyntaxRoot(root.ReplaceNode(structDeclaration, updatedStructDeclaration));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the code fix to add the missing attribute to a target type.
|
||||
/// </summary>
|
||||
/// <param name="document">The original document being fixed.</param>
|
||||
/// <param name="structDeclaration">The <see cref="StructDeclarationSyntax"/> to update.</param>
|
||||
/// <param name="cancellationToken">The cancellation token for the operation.</param>
|
||||
/// <returns>An updated document with the applied code fix, and the return type of the method being <see cref="Task"/>.</returns>
|
||||
private async Task<SyntaxNode> AddMissingAttribute(
|
||||
Document document,
|
||||
StructDeclarationSyntax structDeclaration,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
// Get the semantic model (bail if it's not available)
|
||||
if (await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false) is not SemanticModel semanticModel)
|
||||
{
|
||||
return structDeclaration;
|
||||
}
|
||||
|
||||
// Build the map of attributes to look for
|
||||
if (!semanticModel.Compilation.TryBuildNamedTypeSymbolSet(this.leadingAttributeFullyQualifiedMetadataNames, out ImmutableHashSet<INamedTypeSymbol>? leadingAttributeTypeSymbols))
|
||||
{
|
||||
return structDeclaration;
|
||||
}
|
||||
|
||||
// Also bail if we can't resolve the target attribute symbol (this should really never happen)
|
||||
if (semanticModel.Compilation.GetTypeByMetadataName(this.attributeFullyQualifiedMetadataName) is not INamedTypeSymbol attributeSymbol)
|
||||
{
|
||||
return structDeclaration;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
||||
// Find the index to use to insert the attribute. We want to make it so that if the struct declaration
|
||||
// has a bunch of leading attributes, the new one will be inserted right after that. This way the final list
|
||||
// will be nicely sorted, instead of having attributes interleaving other unrelated attributes, if any.
|
||||
foreach (AttributeListSyntax attributeList in structDeclaration.AttributeLists)
|
||||
{
|
||||
// Make sure we have an attribute to check
|
||||
if (attributeList.Attributes is not [AttributeSyntax attribute, ..])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Resolve the symbol for the attribute (stop here if this failed for whatever reason)
|
||||
if (!semanticModel.GetSymbolInfo(attribute, cancellationToken).TryGetAttributeTypeSymbol(out INamedTypeSymbol? attributeTypeSymbol))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// If the attribute is a leading one, increment the index and continue
|
||||
if (leadingAttributeTypeSymbols.Contains(attributeTypeSymbol))
|
||||
{
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, stop here, we reached the end of the sequence
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SyntaxGenerator syntaxGenerator = SyntaxGenerator.GetGenerator(document);
|
||||
|
||||
// Create the attribute syntax for the new attribute. Also annotate it
|
||||
// to automatically add using directives to the document, if needed.
|
||||
// Then create the attribute syntax and insert it at the right position.
|
||||
SyntaxNode attributeTypeSyntax = syntaxGenerator.TypeExpression(attributeSymbol).WithAdditionalAnnotations(Simplifier.AddImportsAnnotation);
|
||||
SyntaxNode attributeSyntax = syntaxGenerator.Attribute(attributeTypeSyntax);
|
||||
SyntaxNode updatedStructDeclarationSyntax = syntaxGenerator.InsertAttributes(structDeclaration, index, attributeSyntax);
|
||||
|
||||
// Replace the node in the syntax tree
|
||||
return updatedStructDeclarationSyntax;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="FixAllProvider"/> with the logic from <see cref="MissingAttributeCodeFixer"/>.
|
||||
/// </summary>
|
||||
private sealed class FixAllProvider : DocumentBasedFixAllProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The owning <see cref="MissingAttributeCodeFixer"/> instance.
|
||||
/// </summary>
|
||||
private readonly MissingAttributeCodeFixer codeFixer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FixAllProvider"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="codeFixer">The owning <see cref="MissingAttributeCodeFixer"/> instance.</param>
|
||||
public FixAllProvider(MissingAttributeCodeFixer codeFixer)
|
||||
{
|
||||
this.codeFixer = codeFixer;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override async Task<Document?> FixAllAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics)
|
||||
{
|
||||
// Get the document root (this should always succeed)
|
||||
if (await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false) is not SyntaxNode root)
|
||||
{
|
||||
return document;
|
||||
}
|
||||
|
||||
SyntaxEditor syntaxEditor = new(root, fixAllContext.Solution.Services);
|
||||
|
||||
foreach (Diagnostic diagnostic in diagnostics)
|
||||
{
|
||||
// Get the current struct declaration for the diagnostic
|
||||
if (root.FindNode(diagnostic.Location.SourceSpan) is not StructDeclarationSyntax structDeclaration)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the syntax node with the updated declaration
|
||||
SyntaxNode updatedStructDeclaration = await this.codeFixer.AddMissingAttribute(
|
||||
document,
|
||||
structDeclaration,
|
||||
fixAllContext.CancellationToken);
|
||||
|
||||
// Replace the node via the editor
|
||||
syntaxEditor.ReplaceNode(structDeclaration, updatedStructDeclaration);
|
||||
}
|
||||
|
||||
return document.WithSyntaxRoot(syntaxEditor.GetChangedRoot());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,6 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputeSharp.D2D1.SourceGenerators\ComputeSharp.D2D1.SourceGenerators.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\ComputeSharp.CodeFixing\ComputeSharp.CodeFixing.projitems" Label="Shared" />
|
||||
</Project>
|
||||
+13
-173
@@ -1,15 +1,7 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Composition;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.CodeFixing;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CodeActions;
|
||||
using Microsoft.CodeAnalysis.CodeFixes;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Editing;
|
||||
using Microsoft.CodeAnalysis.Simplification;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
|
||||
namespace ComputeSharp.D2D1.CodeFixers;
|
||||
@@ -19,12 +11,13 @@ namespace ComputeSharp.D2D1.CodeFixers;
|
||||
/// </summary>
|
||||
[ExportCodeFixProvider(LanguageNames.CSharp)]
|
||||
[Shared]
|
||||
public sealed class MissingPixelShaderDescriptorOnPixelShaderCodeFixer : CodeFixProvider
|
||||
public sealed class MissingPixelShaderDescriptorOnPixelShaderCodeFixer : MissingAttributeCodeFixer
|
||||
{
|
||||
/// <summary>
|
||||
/// The set of type names for all D2D attributes that can be over shader types.
|
||||
/// </summary>
|
||||
private static readonly ImmutableArray<string> D2DAttributeTypeNames = ImmutableArray.Create(
|
||||
private static readonly string[] D2DAttributeTypeNames = new[]
|
||||
{
|
||||
"ComputeSharp.D2D1.D2DCompileOptionsAttribute",
|
||||
"ComputeSharp.D2D1.D2DEffectAuthorAttribute",
|
||||
"ComputeSharp.D2D1.D2DEffectCategoryAttribute",
|
||||
@@ -38,171 +31,18 @@ public sealed class MissingPixelShaderDescriptorOnPixelShaderCodeFixer : CodeFix
|
||||
"ComputeSharp.D2D1.D2DOutputBufferAttribute",
|
||||
"ComputeSharp.D2D1.D2DPixelOptionsAttribute",
|
||||
"ComputeSharp.D2D1.D2DRequiresScenePositionAttribute",
|
||||
"ComputeSharp.D2D1.D2DShaderProfileAttribute");
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override ImmutableArray<string> FixableDiagnosticIds { get; } = ImmutableArray.Create(MissingPixelShaderDescriptorOnPixelShaderTypeId);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Microsoft.CodeAnalysis.CodeFixes.FixAllProvider? GetFixAllProvider()
|
||||
{
|
||||
return new FixAllProvider();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task RegisterCodeFixesAsync(CodeFixContext context)
|
||||
{
|
||||
Diagnostic diagnostic = context.Diagnostics[0];
|
||||
TextSpan diagnosticSpan = context.Span;
|
||||
|
||||
SyntaxNode? root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Get the struct declaration from the target diagnostic
|
||||
if (root?.FindNode(diagnosticSpan) is StructDeclarationSyntax structDeclaration)
|
||||
{
|
||||
// Register the code fix to update the return type to be Task instead
|
||||
context.RegisterCodeFix(
|
||||
CodeAction.Create(
|
||||
title: "Add [D2DGeneratedPixelShaderDescriptor] attribute",
|
||||
createChangedDocument: token => AddMissingD2DGeneratedPixelShaderDescriptorAttribute(context.Document, root, structDeclaration, token),
|
||||
equivalenceKey: "Add [D2DGeneratedPixelShaderDescriptor] attribute"),
|
||||
diagnostic);
|
||||
}
|
||||
}
|
||||
"ComputeSharp.D2D1.D2DShaderProfileAttribute"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Applies the code fix to add the [D2DGeneratedPixelShaderDescriptor] attribute to a target type.
|
||||
/// Creates a new <see cref="MissingAttributeCodeFixer"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="document">The original document being fixed.</param>
|
||||
/// <param name="root">The original tree root belonging to the current document.</param>
|
||||
/// <param name="structDeclaration">The <see cref="StructDeclarationSyntax"/> to update.</param>
|
||||
/// <param name="cancellationToken">The cancellation token for the operation.</param>
|
||||
/// <returns>An updated document with the applied code fix, and the return type of the method being <see cref="Task"/>.</returns>
|
||||
private static async Task<Document> AddMissingD2DGeneratedPixelShaderDescriptorAttribute(
|
||||
Document document,
|
||||
SyntaxNode root,
|
||||
StructDeclarationSyntax structDeclaration,
|
||||
CancellationToken cancellationToken)
|
||||
public MissingPixelShaderDescriptorOnPixelShaderCodeFixer()
|
||||
: base(
|
||||
diagnosticId: MissingPixelShaderDescriptorOnPixelShaderTypeId,
|
||||
codeActionTitle: "Add [D2DGeneratedPixelShaderDescriptor] attribute",
|
||||
attributeFullyQualifiedMetadataName: "ComputeSharp.D2D1.D2DGeneratedPixelShaderDescriptorAttribute",
|
||||
leadingAttributeFullyQualifiedMetadataNames: D2DAttributeTypeNames)
|
||||
{
|
||||
// Get the new struct declaration
|
||||
SyntaxNode updatedStructDeclaration = await AddMissingD2DGeneratedPixelShaderDescriptorAttribute(
|
||||
document,
|
||||
structDeclaration,
|
||||
cancellationToken);
|
||||
|
||||
// Replace the node in the document tree
|
||||
return document.WithSyntaxRoot(root.ReplaceNode(structDeclaration, updatedStructDeclaration));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the code fix to add the [D2DGeneratedPixelShaderDescriptor] attribute to a target type.
|
||||
/// </summary>
|
||||
/// <param name="document">The original document being fixed.</param>
|
||||
/// <param name="structDeclaration">The <see cref="StructDeclarationSyntax"/> to update.</param>
|
||||
/// <param name="cancellationToken">The cancellation token for the operation.</param>
|
||||
/// <returns>An updated document with the applied code fix, and the return type of the method being <see cref="Task"/>.</returns>
|
||||
private static async Task<SyntaxNode> AddMissingD2DGeneratedPixelShaderDescriptorAttribute(
|
||||
Document document,
|
||||
StructDeclarationSyntax structDeclaration,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
// Get the semantic model (bail if it's not available)
|
||||
if (await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false) is not SemanticModel semanticModel)
|
||||
{
|
||||
return structDeclaration;
|
||||
}
|
||||
|
||||
// Build the map of D2D attributes to look for
|
||||
if (!semanticModel.Compilation.TryBuildNamedTypeSymbolSet(D2DAttributeTypeNames, out ImmutableHashSet<INamedTypeSymbol>? d2DAttributeTypeSymbols))
|
||||
{
|
||||
return structDeclaration;
|
||||
}
|
||||
|
||||
// Also bail if we can't resolve the [D2DGeneratedPixelShaderDescriptor] attribute symbol (this should really never happen)
|
||||
if (semanticModel.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.D2DGeneratedPixelShaderDescriptorAttribute") is not INamedTypeSymbol attributeSymbol)
|
||||
{
|
||||
return structDeclaration;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
||||
// Find the index to use to insert the attribute. We want to make it so that if the struct declaration
|
||||
// has a bunch of D2D attributes, the new one will be inserted right after that. This way the final list
|
||||
// will be nicely sorted, instead of having D2D attributes interleaving other unrelated attributes, if any.
|
||||
foreach (AttributeListSyntax attributeList in structDeclaration.AttributeLists)
|
||||
{
|
||||
// Make sure we have an attribute to check
|
||||
if (attributeList.Attributes is not [AttributeSyntax attribute, ..])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Resolve the symbol for the attribute (stop here if this failed for whatever reason)
|
||||
if (!semanticModel.GetSymbolInfo(attribute, cancellationToken).TryGetAttributeTypeSymbol(out INamedTypeSymbol? attributeTypeSymbol))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// If the attribute is D2D one, increment the index and continue
|
||||
if (d2DAttributeTypeSymbols.Contains(attributeTypeSymbol))
|
||||
{
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, stop here, we reached the end of the sequence
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SyntaxGenerator syntaxGenerator = SyntaxGenerator.GetGenerator(document);
|
||||
|
||||
// Create the attribute syntax for the new attribute. Also annotate it
|
||||
// to automatically add using directives to the document, if needed.
|
||||
// Then create the attribute syntax and insert it at the right position.
|
||||
SyntaxNode attributeTypeSyntax = syntaxGenerator.TypeExpression(attributeSymbol).WithAdditionalAnnotations(Simplifier.AddImportsAnnotation);
|
||||
SyntaxNode attributeSyntax = syntaxGenerator.Attribute(attributeTypeSyntax);
|
||||
SyntaxNode updatedStructDeclarationSyntax = syntaxGenerator.InsertAttributes(structDeclaration, index, attributeSyntax);
|
||||
|
||||
// Replace the node in the syntax tree
|
||||
return updatedStructDeclarationSyntax;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="FixAllProvider"/> with the logic from <see cref="MissingPixelShaderDescriptorOnPixelShaderCodeFixer"/>.
|
||||
/// </summary>
|
||||
private sealed class FixAllProvider : DocumentBasedFixAllProvider
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override async Task<Document?> FixAllAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics)
|
||||
{
|
||||
// Get the document root (this should always succeed)
|
||||
if (await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false) is not SyntaxNode root)
|
||||
{
|
||||
return document;
|
||||
}
|
||||
|
||||
SyntaxEditor syntaxEditor = new(root, fixAllContext.Solution.Services);
|
||||
|
||||
foreach (Diagnostic diagnostic in diagnostics)
|
||||
{
|
||||
// Get the current struct declaration for the diagnostic
|
||||
if (root.FindNode(diagnostic.Location.SourceSpan) is not StructDeclarationSyntax structDeclaration)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the syntax node with the updated declaration
|
||||
SyntaxNode updatedStructDeclaration = await AddMissingD2DGeneratedPixelShaderDescriptorAttribute(
|
||||
document,
|
||||
structDeclaration,
|
||||
fixAllContext.CancellationToken);
|
||||
|
||||
// Replace the node via the editor
|
||||
syntaxEditor.ReplaceNode(structDeclaration, updatedStructDeclaration);
|
||||
}
|
||||
|
||||
return document.WithSyntaxRoot(syntaxEditor.GetChangedRoot());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,8 +43,6 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene
|
||||
return default;
|
||||
}
|
||||
|
||||
StructDeclarationSyntax typeDeclaration = (StructDeclarationSyntax)context.TargetNode;
|
||||
|
||||
// Check that the shader implements the ID2D1PixelShader interface
|
||||
if (!typeSymbol.HasInterfaceWithType(context.SemanticModel.Compilation.GetTypeByMetadataName("ComputeSharp.D2D1.ID2D1PixelShader")!))
|
||||
{
|
||||
@@ -110,7 +108,7 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene
|
||||
string hlslSource = HlslSource.GetHlslSource(
|
||||
diagnostics,
|
||||
context.SemanticModel.Compilation,
|
||||
typeDeclaration,
|
||||
(StructDeclarationSyntax)context.TargetNode,
|
||||
typeSymbol,
|
||||
inputCount,
|
||||
inputSimpleIndices,
|
||||
|
||||
@@ -15,13 +15,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an invalid shader field.
|
||||
/// <para>
|
||||
/// Format: <c>"The compute shader of type {0} contains a field \"{1}\" of an invalid type {2}"</c>.
|
||||
/// Format: <c>"The compute shader of type {0} contains a field "{1}" of an invalid type {2}"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidShaderField = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0001",
|
||||
title: "Invalid shader field",
|
||||
messageFormat: "The compute shader of type {0} contains a field \"{1}\" of an invalid type {2}",
|
||||
messageFormat: """The compute shader of type {0} contains a field "{1}" of an invalid type {2}""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -401,13 +401,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an invalid shader static readonly field type.
|
||||
/// <para>
|
||||
/// Format: <c>"The compute shader of type {0} contains a static readonly field \"{1}\" of an invalid type {2} (only primitive, vector and matrix types are supported)"</c>.
|
||||
/// Format: <c>"The compute shader of type {0} contains a static readonly field "{1}" of an invalid type {2} (only primitive, vector and matrix types are supported)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidShaderStaticFieldType = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0030",
|
||||
title: "Invalid shader static readonly field type",
|
||||
messageFormat: "The compute shader of type {0} contains a static readonly field \"{1}\" of an invalid type {2} (only primitive, vector and matrix types are supported)",
|
||||
messageFormat: """The compute shader of type {0} contains a static readonly field "{1}" of an invalid type {2} (only primitive, vector and matrix types are supported)""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -417,13 +417,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a property declaration.
|
||||
/// <para>
|
||||
/// Format: <c>"The D2D1 shader of type {0} contains an invalid property \"{1}\" declaration (only stateless properties explicitly implementing an interface property can be used)"</c>.
|
||||
/// Format: <c>"The D2D1 shader of type {0} contains an invalid property "{1}" declaration (only stateless properties explicitly implementing an interface property can be used)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidPropertyDeclaration = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0031",
|
||||
title: "Invalid property declaration",
|
||||
messageFormat: "The D2D1 shader of type {0} contains an invalid property \"{1}\" declaration (only stateless properties explicitly implementing an interface property can be used)",
|
||||
messageFormat: """The D2D1 shader of type {0} contains an invalid property "{1}" declaration (only stateless properties explicitly implementing an interface property can be used)""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -455,7 +455,7 @@ partial class DiagnosticDescriptors
|
||||
public static readonly DiagnosticDescriptor EmbeddedBytecodeFailedWithWin32Exception = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0033",
|
||||
title: "Embedded 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}\")",
|
||||
messageFormat: """The shader of type {0} failed to compile due to a Win32 exception (HRESULT: {1:X8}, Message: "{2}")""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -471,7 +471,7 @@ partial class DiagnosticDescriptors
|
||||
public static readonly DiagnosticDescriptor EmbeddedBytecodeFailedWithFxcCompilationException = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0034",
|
||||
title: "Embedded 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}\")",
|
||||
messageFormat: """The shader of type {0} failed to compile due to an HLSL compiler error (Message: "{1}")""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -706,13 +706,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an invalid use of <c>[D2DResourceTextureIndex]</c>.
|
||||
/// <para>
|
||||
/// Format: <c>"The field \"{0}\" (in type {1}) is using [D2DResourceTextureIndex] incorrectly (the attribute can only be used on D2D1 resource texture types, but the field is of type {2})"</c>.
|
||||
/// Format: <c>"The field "{0}" (in type {1}) is using [D2DResourceTextureIndex] incorrectly (the attribute can only be used on D2D1 resource texture types, but the field is of type {2})"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidD2DResourceTextureIndexAttributeUse = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0049",
|
||||
title: "Invalid [D2DResourceTextureIndex] use",
|
||||
messageFormat: "The field \"{0}\" (in type {1}) is using [D2DResourceTextureIndex] incorrectly (the attribute can only be used on D2D1 resource texture types, but the field is of type {2})",
|
||||
messageFormat: """The field "{0}" (in type {1}) is using [D2DResourceTextureIndex] incorrectly (the attribute can only be used on D2D1 resource texture types, but the field is of type {2})""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -722,13 +722,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a missing <c>[D2DResourceTextureIndex]</c>.
|
||||
/// <para>
|
||||
/// Format: <c>"The field \"{0}\" (in type {1}) is of a D2D1 resource texture type but is missing the [D2DResourceTextureIndex] attribute"</c>.
|
||||
/// Format: <c>"The field "{0}" (in type {1}) is of a D2D1 resource texture type but is missing the [D2DResourceTextureIndex] attribute"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor MissingD2DResourceTextureIndexAttribute = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0050",
|
||||
title: "Missing [D2DResourceTextureIndex] attribute",
|
||||
messageFormat: "The field \"{0}\" (in type {1}) is of a D2D1 resource texture type but is missing the [D2DResourceTextureIndex] attribute",
|
||||
messageFormat: """The field "{0}" (in type {1}) is of a D2D1 resource texture type but is missing the [D2DResourceTextureIndex] attribute""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -738,13 +738,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a resource texture using an invalid element type.
|
||||
/// <para>
|
||||
/// Format: <c>"The field \"{0}\" (in type {1}) using a D2D1 resource texture of type {2} has an invalid element type (only float and float4 type arguments are supported)"</c>.
|
||||
/// Format: <c>"The field "{0}" (in type {1}) using a D2D1 resource texture of type {2} has an invalid element type (only float and float4 type arguments are supported)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidResourceTextureElementType = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0051",
|
||||
title: "Invalid D2D1 resource texture element type",
|
||||
messageFormat: "The field \"{0}\" (in type {1}) using a D2D1 resource texture of type {2} has an invalid element type (only float and float4 type arguments are supported)",
|
||||
messageFormat: """The field "{0}" (in type {1}) using a D2D1 resource texture of type {2} has an invalid element type (only float and float4 type arguments are supported)""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -754,13 +754,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an invalid HLSL source in <c>[D2DPixelShaderSource]</c>.
|
||||
/// <para>
|
||||
/// Format: <c>"The method \"{0}\" (in type {1}) is using [D2DPixelShaderSource] with an invalid HLSL source argument"</c>.
|
||||
/// Format: <c>"The method "{0}" (in type {1}) is using [D2DPixelShaderSource] with an invalid HLSL source argument"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidD2DPixelShaderSource = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0052",
|
||||
title: "Invalid [D2DPixelShaderSource] HLSL source argument",
|
||||
messageFormat: "The method \"{0}\" (in type {1}) is using [D2DPixelShaderSource] with an invalid HLSL source argument",
|
||||
messageFormat: """The method "{0}" (in type {1}) is using [D2DPixelShaderSource] with an invalid HLSL source argument""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -770,13 +770,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an embedded bytecode D2D shader failed due to a Win32 exception.
|
||||
/// <para>
|
||||
/// Format: <c>"Compiling the HLSL source for method \"{1}\" (in type {0}) failed due to a Win32 exception (HRESULT: {2:X8}, Message: \"{3}\")"</c>.
|
||||
/// Format: <c>"Compiling the HLSL source for method "{1}" (in type {0}) failed due to a Win32 exception (HRESULT: {2:X8}, Message: "{3}")"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor D2DPixelShaderSourceCompilationFailedWithWin32Exception = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0053",
|
||||
title: "D2D shader compilation failed due to Win32 exception",
|
||||
messageFormat: "Compiling the HLSL source for method \"{1}\" (in type {0}) failed due to a Win32 exception (HRESULT: {2:X8}, Message: \"{3}\")",
|
||||
messageFormat: """Compiling the HLSL source for method "{1}" (in type {0}) failed due to a Win32 exception (HRESULT: {2:X8}, Message: "{3}")""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -786,13 +786,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an embedded bytecode D2D shader failed due to an HLSL compilation exception.
|
||||
/// <para>
|
||||
/// Format: <c>"Compiling the HLSL source for method \"{1}\" (in type {0}) failed due to an HLSL compiler error (Message: \"{2}\")"</c>.
|
||||
/// Format: <c>"Compiling the HLSL source for method "{1}" (in type {0}) failed due to an HLSL compiler error (Message: "{2}")"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor D2DPixelShaderSourceCompilationFailedWithFxcCompilationException = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0054",
|
||||
title: "D2D shader compilation failed due to an HLSL compiler error",
|
||||
messageFormat: "Compiling the HLSL source for method \"{1}\" (in type {0}) failed due to an HLSL compiler error (Message: \"{2}\")",
|
||||
messageFormat: """Compiling the HLSL source for method "{1}" (in type {0}) failed due to an HLSL compiler error (Message: "{2}")""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -802,13 +802,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an embedded bytecode D2D shader with no shader profile set.
|
||||
/// <para>
|
||||
/// Format: <c>"The method \"{0}\" (in type {1}) is using [D2DPixelShaderSource] but has not specified the shader profile to use"</c>.
|
||||
/// Format: <c>"The method "{0}" (in type {1}) is using [D2DPixelShaderSource] but has not specified the shader profile to use"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor MissingShaderProfileForD2DPixelShaderSource = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0055",
|
||||
title: "Missing shader profile for D2D pixel shader source",
|
||||
messageFormat: "The method \"{0}\" (in type {1}) is using [D2DPixelShaderSource] but has not specified the shader profile to use",
|
||||
messageFormat: """The method "{0}" (in type {1}) is using [D2DPixelShaderSource] but has not specified the shader profile to use""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -818,13 +818,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an embedded bytecode D2D shader with no compile options set.
|
||||
/// <para>
|
||||
/// Format: <c>"The method \"{0}\" (in type {1}) is using [D2DPixelShaderSource] but has not specified the compile options to use"</c>.
|
||||
/// Format: <c>"The method "{0}" (in type {1}) is using [D2DPixelShaderSource] but has not specified the compile options to use"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor MissingCompileOptionsForD2DPixelShaderSource = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0056",
|
||||
title: "Missing compile options for D2D pixel shader source",
|
||||
messageFormat: "The method \"{0}\" (in type {1}) is using [D2DPixelShaderSource] but has not specified the compile options to use",
|
||||
messageFormat: """The method "{0}" (in type {1}) is using [D2DPixelShaderSource] but has not specified the compile options to use""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -834,13 +834,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for when a method with [D2DPixelShaderSource] has an invalid return type.
|
||||
/// <para>
|
||||
/// Format: <c>"The method \"{0}\" (in type {1}) is using [D2DPixelShaderSource] but has an invalid return type {2} (it must return a ReadOnlySpan<byte>)"</c>.
|
||||
/// Format: <c>"The method "{0}" (in type {1}) is using [D2DPixelShaderSource] but has an invalid return type {2} (it must return a ReadOnlySpan<byte>)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidD2DPixelShaderSourceMethodReturnType = new DiagnosticDescriptor(
|
||||
id: "CMPSD2D0057",
|
||||
title: "Missing compile options for D2D pixel shader source",
|
||||
messageFormat: "The method \"{0}\" (in type {1}) is using [D2DPixelShaderSource] but has an invalid return type {2} (it must return a ReadOnlySpan<byte>)",
|
||||
messageFormat: """The method "{0}" (in type {1}) is using [D2DPixelShaderSource] but has an invalid return type {2} (it must return a ReadOnlySpan<byte>)""",
|
||||
category: "ComputeSharp.D2D1.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
|
||||
@@ -58,3 +58,5 @@ CMPS0049 | ComputeSharp.Shaders | Error | [Documentation](https://github.com/Ser
|
||||
CMPS0050 | ComputeSharp.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0051 | ComputeSharp | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0052 | ComputeSharp.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0053 | ComputeSharp.Shaders | Warning | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
CMPS0054 | ComputeSharp.Shaders | Error | [Documentation](https://github.com/Sergio0694/ComputeSharp)
|
||||
@@ -25,8 +25,7 @@ partial class ComputeShaderDescriptorGenerator
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (interfaceSymbol is { IsGenericType: true } &&
|
||||
SymbolEqualityComparer.Default.Equals(interfaceSymbol.ConstructedFrom, pixelShaderSymbol))
|
||||
else if (SymbolEqualityComparer.Default.Equals(interfaceSymbol.ConstructedFrom, pixelShaderSymbol))
|
||||
{
|
||||
result = true;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
using ComputeSharp.SourceGenerators.Models;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
@@ -27,7 +26,8 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener
|
||||
// Discover all shader types and extract all the necessary info from each of them
|
||||
IncrementalValuesProvider<ShaderInfo> shaderInfo =
|
||||
context.SyntaxProvider
|
||||
.CreateSyntaxProvider(
|
||||
.ForAttributeWithMetadataName(
|
||||
"ComputeSharp.GeneratedComputeShaderDescriptorAttribute",
|
||||
static (node, _) => node.IsTypeDeclarationWithOrPotentiallyWithBaseTypes<StructDeclarationSyntax>(),
|
||||
static (context, token) =>
|
||||
{
|
||||
@@ -37,10 +37,8 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener
|
||||
return default;
|
||||
}
|
||||
|
||||
StructDeclarationSyntax typeDeclaration = (StructDeclarationSyntax)context.Node;
|
||||
|
||||
// If the type symbol doesn't have at least one interface, it can't possibly be a shader type
|
||||
if (context.SemanticModel.GetDeclaredSymbol(typeDeclaration, token) is not INamedTypeSymbol { AllInterfaces.Length: > 0 } typeSymbol)
|
||||
if (context.TargetSymbol is not INamedTypeSymbol { AllInterfaces.Length: > 0 } typeSymbol)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
@@ -78,7 +76,7 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener
|
||||
HlslSource.GetInfo(
|
||||
diagnostics,
|
||||
context.SemanticModel.Compilation,
|
||||
typeDeclaration,
|
||||
(StructDeclarationSyntax)context.TargetNode,
|
||||
typeSymbol,
|
||||
threadsX,
|
||||
threadsY,
|
||||
|
||||
@@ -97,4 +97,9 @@
|
||||
|
||||
<!-- Shared projects with .NET Standard 2.0 polyfills -->
|
||||
<Import Project="..\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems" Label="Shared" />
|
||||
|
||||
<!-- Give access to the code fixers project for the exported diagnostic ids and properties -->
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="ComputeSharp.CodeFixers, PublicKey=$(AssemblySignPublicKey)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Diagnostics;
|
||||
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <summary>
|
||||
/// A diagnostic analyzer that generates an error whenever the [GeneratedComputeShaderDescriptor] attribute is used on an invalid target type.
|
||||
/// </summary>
|
||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||
public sealed class InvalidGeneratedComputeShaderDescriptorAttributeTargetAnalyzer : DiagnosticAnalyzer
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(InvalidGeneratedPixelShaderDescriptorAttributeTarget);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize(AnalysisContext context)
|
||||
{
|
||||
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
|
||||
context.EnableConcurrentExecution();
|
||||
|
||||
context.RegisterCompilationStartAction(static context =>
|
||||
{
|
||||
// Get the IComputeShader, IComputeShader<TPixel> and [GeneratedComputeShaderDescriptor] symbols
|
||||
if (context.Compilation.GetTypeByMetadataName("ComputeSharp.IComputeShader") is not { } computeShaderSymbol ||
|
||||
context.Compilation.GetTypeByMetadataName("ComputeSharp.IComputeShader`1") is not { } pixelShaderSymbol ||
|
||||
context.Compilation.GetTypeByMetadataName("ComputeSharp.GeneratedComputeShaderDescriptorAttribute") is not { } generatedComputeShaderDescriptorAttributeSymbol)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
context.RegisterSymbolAction(context =>
|
||||
{
|
||||
// Only struct types are possible targets
|
||||
if (context.Symbol is not INamedTypeSymbol { TypeKind: TypeKind.Struct } typeSymbol)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the current type does not have [GeneratedComputeShaderDescriptor], there is nothing to do
|
||||
if (!typeSymbol.TryGetAttributeWithType(generatedComputeShaderDescriptorAttributeSymbol, out AttributeData? attribute))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the type doesn't implement IComputeShader nor IComputeShader<TPixel>, we can emit a diagnostic
|
||||
if (!MissingComputeShaderDescriptorOnComputeShaderAnalyzer.IsComputeShaderType(typeSymbol, computeShaderSymbol, pixelShaderSymbol))
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
InvalidGeneratedPixelShaderDescriptorAttributeTarget,
|
||||
attribute.GetLocation(),
|
||||
typeSymbol));
|
||||
}
|
||||
}, SymbolKind.NamedType);
|
||||
});
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Diagnostics;
|
||||
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <summary>
|
||||
/// A diagnostic analyzer that generates a warning whenever a compute shader type does not have an associated descriptor.
|
||||
/// </summary>
|
||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||
public sealed class MissingComputeShaderDescriptorOnComputeShaderAnalyzer : DiagnosticAnalyzer
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(MissingComputeShaderDescriptorOnComputeShaderType);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize(AnalysisContext context)
|
||||
{
|
||||
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
|
||||
context.EnableConcurrentExecution();
|
||||
|
||||
context.RegisterCompilationStartAction(static context =>
|
||||
{
|
||||
// Get the IComputeShader, IComputeShader<TPixel>, IComputeShaderDescriptor<T> and [GeneratedComputeShaderDescriptor] symbols
|
||||
if (context.Compilation.GetTypeByMetadataName("ComputeSharp.IComputeShader") is not { } computeShaderSymbol ||
|
||||
context.Compilation.GetTypeByMetadataName("ComputeSharp.IComputeShader`1") is not { } pixelShaderSymbol ||
|
||||
context.Compilation.GetTypeByMetadataName("ComputeSharp.Descriptors.IComputeShaderDescriptor`1") is not { } computeShaderDescriptorSymbol ||
|
||||
context.Compilation.GetTypeByMetadataName("ComputeSharp.GeneratedComputeShaderDescriptorAttribute") is not { } generatedComputeShaderDescriptorAttributeSymbol)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
context.RegisterSymbolAction(context =>
|
||||
{
|
||||
// Only struct types are possible targets
|
||||
if (context.Symbol is not INamedTypeSymbol { TypeKind: TypeKind.Struct } typeSymbol)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the type is not a compute shader type, immediately bail out
|
||||
if (!IsComputeShaderType(typeSymbol, computeShaderSymbol, pixelShaderSymbol))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Emit a diagnostic if the descriptor is missing for the shader type
|
||||
if (!typeSymbol.HasInterfaceWithType(computeShaderDescriptorSymbol) &&
|
||||
!typeSymbol.HasAttributeWithType(generatedComputeShaderDescriptorAttributeSymbol))
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
MissingComputeShaderDescriptorOnComputeShaderType,
|
||||
typeSymbol.Locations.FirstOrDefault(),
|
||||
typeSymbol));
|
||||
}
|
||||
}, SymbolKind.NamedType);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a given type is a compute shader type.
|
||||
/// </summary>
|
||||
/// <param name="typeSymbol">The type to check.</param>
|
||||
/// <param name="computeShaderSymbol">The type symbol for <c>IComputeShader</c>.</param>
|
||||
/// <param name="pixelShaderSymbol">The type symbol for <c>IComputeShader<TPixel></c>.</param>
|
||||
/// <returns></returns>
|
||||
internal static bool IsComputeShaderType(
|
||||
INamedTypeSymbol typeSymbol,
|
||||
INamedTypeSymbol computeShaderSymbol,
|
||||
INamedTypeSymbol pixelShaderSymbol)
|
||||
{
|
||||
foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.AllInterfaces)
|
||||
{
|
||||
if (SymbolEqualityComparer.Default.Equals(interfaceSymbol, computeShaderSymbol) ||
|
||||
SymbolEqualityComparer.Default.Equals(interfaceSymbol.ConstructedFrom, pixelShaderSymbol))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,11 @@ namespace ComputeSharp.SourceGeneration.Diagnostics;
|
||||
/// <inheritdoc/>
|
||||
partial class DiagnosticDescriptors
|
||||
{
|
||||
/// <summary>
|
||||
/// The diagnostic id for <see cref="MissingComputeShaderDescriptorOnComputeShaderType"/>.
|
||||
/// </summary>
|
||||
public const string MissingComputeShaderDescriptorOnComputeShaderTypeId = "CMPS0053";
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an invalid shader field.
|
||||
/// <para>
|
||||
@@ -16,7 +21,7 @@ partial class DiagnosticDescriptors
|
||||
public static readonly DiagnosticDescriptor InvalidShaderField = new DiagnosticDescriptor(
|
||||
id: "CMPS0001",
|
||||
title: "Invalid shader field",
|
||||
messageFormat: "The compute shader of type {0} contains a field \"{1}\" of an invalid type {2}",
|
||||
messageFormat: """The compute shader of type {0} contains a field "{1}" of an invalid type {2}""",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -32,7 +37,7 @@ partial class DiagnosticDescriptors
|
||||
public static readonly DiagnosticDescriptor InvalidGroupSharedFieldType = new DiagnosticDescriptor(
|
||||
id: "CMPS0002",
|
||||
title: "Invalid group shared field type",
|
||||
messageFormat: "The compute shader of type {0} contains a group shared field \"{1}\" of an invalid type {2} (it must be an array)",
|
||||
messageFormat: """The compute shader of type {0} contains a group shared field "{1}" of an invalid type {2} (it must be an array)""",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -48,7 +53,7 @@ partial class DiagnosticDescriptors
|
||||
public static readonly DiagnosticDescriptor InvalidGroupSharedFieldElementType = new DiagnosticDescriptor(
|
||||
id: "CMPS0003",
|
||||
title: "Invalid group shared field element type",
|
||||
messageFormat: "The compute shader of type {0} contains a group shared field \"{1}\" of an invalid type {2} (it must be a primitive or unmanaged type)",
|
||||
messageFormat: """The compute shader of type {0} contains a group shared field "{1}" of an invalid type {2} (it must be a primitive or unmanaged type)""",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -64,7 +69,7 @@ partial class DiagnosticDescriptors
|
||||
public static readonly DiagnosticDescriptor InvalidGroupSharedFieldDeclaration = new DiagnosticDescriptor(
|
||||
id: "CMPS0004",
|
||||
title: "Invalid group shared field declaration",
|
||||
messageFormat: "The compute shader of type {0} contains a group shared field \"{1}\" that is not static",
|
||||
messageFormat: """The compute shader of type {0} contains a group shared field "{1}" that is not static""",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -512,13 +517,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for an invalid shader static field type.
|
||||
/// <para>
|
||||
/// Format: <c>"The compute shader of type {0} contains a static field \"{1}\" of an invalid type {2} (only primitive, vector and matrix types are supported)"</c>.
|
||||
/// Format: <c>"The compute shader of type {0} contains a static field "{1}" of an invalid type {2} (only primitive, vector and matrix types are supported)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidShaderStaticFieldType = new DiagnosticDescriptor(
|
||||
id: "CMPS0038",
|
||||
title: "Invalid shader static field type",
|
||||
messageFormat: "The compute shader of type {0} contains a static field \"{1}\" of an invalid type {2} (only primitive, vector and matrix types are supported)",
|
||||
messageFormat: """The compute shader of type {0} contains a static field "{1}" of an invalid type {2} (only primitive, vector and matrix types are supported)""",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -541,13 +546,13 @@ partial class DiagnosticDescriptors
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for a property declaration.
|
||||
/// <para>
|
||||
/// Format: <c>"The compute shader of type {0} contains an invalid property \"{1}\" declaration (only stateless properties explicitly implementing an interface property can be used)"</c>.
|
||||
/// Format: <c>"The compute shader of type {0} contains an invalid property "{1}" declaration (only stateless properties explicitly implementing an interface property can be used)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidPropertyDeclaration = new DiagnosticDescriptor(
|
||||
id: "CMPS0040",
|
||||
title: "Invalid property declaration",
|
||||
messageFormat: "The compute shader of type {0} contains an invalid property \"{1}\" declaration (only stateless properties explicitly implementing an interface property can be used)",
|
||||
messageFormat: """The compute shader of type {0} contains an invalid property "{1}" declaration (only stateless properties explicitly implementing an interface property can be used)""",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
@@ -611,7 +616,7 @@ partial class DiagnosticDescriptors
|
||||
public static readonly DiagnosticDescriptor EmbeddedBytecodeFailedWithWin32Exception = new DiagnosticDescriptor(
|
||||
id: "CMPS0045",
|
||||
title: "Embedded 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}\")",
|
||||
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,
|
||||
@@ -627,7 +632,7 @@ partial class DiagnosticDescriptors
|
||||
public static readonly DiagnosticDescriptor EmbeddedBytecodeFailedWithDxcCompilationException = new DiagnosticDescriptor(
|
||||
id: "CMPS0046",
|
||||
title: "Embedded 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}\")",
|
||||
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,
|
||||
@@ -730,4 +735,37 @@ partial class DiagnosticDescriptors
|
||||
description: "Unsafe blocks must be enabled for the source generators to emit valid code (the <AllowUnsafeBlocks>true</AllowUnsafeBlocks> option must be set in the .csproj/.props file).",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp",
|
||||
customTags: WellKnownDiagnosticTags.CompilationEnd);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for when a compute shader type doesn't have an associated descriptor.
|
||||
/// <para>
|
||||
/// Format: <c>"The compute shader of type {0} does not have an associated descriptor (it can be autogenerated via the [GeneratedComputeShaderDescriptor] attribute)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor MissingComputeShaderDescriptorOnComputeShaderType = new DiagnosticDescriptor(
|
||||
id: MissingComputeShaderDescriptorOnComputeShaderTypeId,
|
||||
title: "Missing descriptor for compute pixel shader type",
|
||||
messageFormat: "The compute shader of type {0} does not have an associated descriptor (it can be autogenerated via the [GeneratedComputeShaderDescriptor] attribute)",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Warning,
|
||||
isEnabledByDefault: true,
|
||||
description: "All compute shader types must have an associated descriptor (it can be autogenerated via the [GeneratedComputeShaderDescriptor] attribute).",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp",
|
||||
customTags: WellKnownDiagnosticTags.CompilationEnd);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DiagnosticDescriptor"/> for when the <c>[GeneratedComputeShaderDescriptor]</c> attribute is being used on an invalid target type.
|
||||
/// <para>
|
||||
/// Format: <c>"The type {0} is not a valid target for the [GeneratedComputeShaderDescriptor] attribute (only types implementing the IComputeShader or IComputeShader<TPixel> interface are valid)"</c>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static readonly DiagnosticDescriptor InvalidGeneratedPixelShaderDescriptorAttributeTarget = new DiagnosticDescriptor(
|
||||
id: "CMPS0054",
|
||||
title: "Invalid [GeneratedComputeShaderDescriptor] attribute target",
|
||||
messageFormat: "The type {0} is not a valid target for the [GeneratedComputeShaderDescriptor] attribute (only types implementing the IComputeShader or IComputeShader<TPixel> interface are valid)",
|
||||
category: "ComputeSharp.Shaders",
|
||||
defaultSeverity: DiagnosticSeverity.Error,
|
||||
isEnabledByDefault: true,
|
||||
description: "The [GeneratedComputeShaderDescriptor] attribute must be used on types that implement the IComputeShader or IComputeShader<TPixel> interfaces.",
|
||||
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// An attribute that indicates that a given compute shader should have its associated descriptor code being generated.
|
||||
/// <para>
|
||||
/// This attribute can be used on shader types that are declared as <see langword="partial"/>:
|
||||
/// <code>
|
||||
/// [GeneratedComputeShaderDescriptor]
|
||||
/// partial struct MyShader : IComputeShader
|
||||
/// {
|
||||
/// }
|
||||
/// </code>
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The shader type must implement either <see cref="IComputeShader"/> or <see cref="IComputeShader{TPixel}"/>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// When a shader is annotated with <see cref="GeneratedComputeShaderDescriptorAttribute"/>, the source generator will also add
|
||||
/// <see cref="Descriptors.IComputeShaderDescriptor{T}"/> to its implemented interfaces, and implement its APIs automatically.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
|
||||
public sealed class GeneratedComputeShaderDescriptorAttribute : Attribute
|
||||
{
|
||||
}
|
||||
@@ -35,6 +35,7 @@ Trace.Assert(shaderInfo.BoundResourceCount == 2);
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct MultiplyByTwo : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
@@ -30,6 +30,7 @@ for (int i = 0; i < array.Length; i++)
|
||||
/// A sample kernel that is precompiled.
|
||||
/// </summary>
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct MultiplyByTwo : IComputeShader
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ for (int i = 0; i < array.Length; i++)
|
||||
/// A sample kernel that is precompiled.
|
||||
/// </summary>
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct MultiplyByTwo : IComputeShader
|
||||
{
|
||||
|
||||
@@ -144,6 +144,7 @@ public partial class DeviceDisposalTests
|
||||
}
|
||||
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
[AutoConstructor]
|
||||
private readonly partial struct InitializeShader : IComputeShader
|
||||
{
|
||||
@@ -177,6 +178,7 @@ public partial class DeviceDisposalTests
|
||||
}
|
||||
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
private partial struct HelloWorldShader : IComputeShader<float4>
|
||||
{
|
||||
public float4 Execute()
|
||||
|
||||
@@ -32,6 +32,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(32, 1, 1)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ComputeShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
@@ -76,6 +77,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct PixelShader : IComputeShader<float4>
|
||||
{
|
||||
private readonly float b;
|
||||
|
||||
@@ -23,6 +23,7 @@ Console.WriteLine("Test passed successfully!");
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct ApplyFunctionShader : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<float> sourceTexture;
|
||||
|
||||
@@ -11,6 +11,7 @@ public partial class ShaderDataLoaderTests
|
||||
{
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public partial struct CapturedResourceShader : IComputeShader
|
||||
{
|
||||
public ReadWriteBuffer<float> _;
|
||||
@@ -46,6 +47,7 @@ public partial class ShaderDataLoaderTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public partial struct MultipleResourcesAndPrimitivesShader : IComputeShader
|
||||
{
|
||||
public ReadWriteBuffer<float> _0;
|
||||
@@ -91,6 +93,7 @@ public partial class ShaderDataLoaderTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public partial struct ScalarAndVectorTypesShader : IComputeShader
|
||||
{
|
||||
public ReadWriteBuffer<float> _;
|
||||
@@ -141,6 +144,7 @@ public partial class ShaderDataLoaderTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public partial struct ScalarVectorAndMatrixTypesShader : IComputeShader
|
||||
{
|
||||
public ReadWriteBuffer<float> _;
|
||||
@@ -226,6 +230,7 @@ public partial class ShaderDataLoaderTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public partial struct FlatCustomTypeShader : IComputeShader
|
||||
{
|
||||
public ReadWriteBuffer<float> _0;
|
||||
@@ -317,6 +322,7 @@ public partial class ShaderDataLoaderTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public partial struct NestedCustomTypesShader : IComputeShader
|
||||
{
|
||||
public ReadWriteBuffer<float> _0;
|
||||
@@ -408,6 +414,7 @@ public partial class ShaderDataLoaderTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public partial struct AmbiguousNamesShader : IComputeShader
|
||||
{
|
||||
public ReadWriteBuffer<float> a;
|
||||
|
||||
@@ -4,14 +4,17 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
|
||||
<PackageReference Include="Basic.Reference.Assemblies.Net70" Version="1.4.5" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.6.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.Core.SourceGenerators\ComputeSharp.Core.SourceGenerators.csproj" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.Core\ComputeSharp.Core.csproj" Aliases="Core" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" Aliases="D3D12" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -279,6 +279,7 @@ public partial class BufferTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ConstantBufferKernel : IComputeShader
|
||||
{
|
||||
public readonly ConstantBuffer<int> source;
|
||||
@@ -308,6 +309,7 @@ public partial class BufferTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyBufferKernel : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyBuffer<int> source;
|
||||
@@ -337,6 +339,7 @@ public partial class BufferTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteBufferKernel : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> source;
|
||||
@@ -373,6 +376,7 @@ public partial class BufferTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct DoublePrecisionSupportShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<double> buffer;
|
||||
|
||||
@@ -1295,6 +1295,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct OffsetComputeShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -1309,6 +1310,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ClearPixelShader : IComputeShader<float4>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
@@ -1320,6 +1322,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ColorPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly float4 color;
|
||||
@@ -1333,6 +1336,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct LinearSampling2DPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly IReadOnlyTexture2D<float4> source;
|
||||
@@ -1346,6 +1350,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct LinearSampling3DComputeShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyTexture3D<float4> source;
|
||||
@@ -1365,6 +1370,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct LinearSamplingFromNormalized2DPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture2D<float4> source;
|
||||
@@ -1378,6 +1384,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct CopyToOutputPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture2D<float4> source;
|
||||
@@ -1391,6 +1398,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct InvertPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly IReadWriteNormalizedTexture2D<float4> source;
|
||||
@@ -1404,6 +1412,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct LinearSamplingFromNormalized3DComputeShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture3D<float4> source;
|
||||
@@ -1423,6 +1432,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Dotted2DPixelShader : IComputeShader
|
||||
{
|
||||
public readonly IReadWriteNormalizedTexture2D<float4> source;
|
||||
@@ -1452,6 +1462,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Dotted3DPixelShader : IComputeShader
|
||||
{
|
||||
public readonly IReadWriteNormalizedTexture3D<float4> source;
|
||||
@@ -1481,6 +1492,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ConvertToNonNormalized2DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture2D<float4> source;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.CodeFixers\ComputeSharp.CodeFixers.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.Core\ComputeSharp.Core.csproj" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.Core.SourceGenerators\ComputeSharp.Core.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="contentfiles;build" />
|
||||
<ProjectReference Include="..\..\src\ComputeSharp.D3D12MemoryAllocator\ComputeSharp.D3D12MemoryAllocator.csproj" Condition="'$(UseD3D12MemoryAllocator)' == 'true'" />
|
||||
|
||||
@@ -58,6 +58,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ThreadIdsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture3D<int4> buffer;
|
||||
@@ -113,6 +114,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ThreadIdsNormalizedShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture3D<float4> buffer;
|
||||
@@ -155,6 +157,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct GroupIdsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture3D<int4> buffer;
|
||||
@@ -186,6 +189,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(4, 15, 7)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct GroupSizeShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -219,6 +223,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(32, 1, 1)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct GridIdsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -251,6 +256,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct DispatchSizeShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -291,6 +297,7 @@ public partial class DispatchTests
|
||||
}
|
||||
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct DispatchPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public float4 Execute()
|
||||
@@ -321,6 +328,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct FixedGroupSharedPixelShader : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -365,6 +373,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(32, 1, 1)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct DynamicGroupSharedPixelShader : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<int> buffer;
|
||||
|
||||
@@ -36,6 +36,7 @@ public partial class IPixelShaderTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct EarlyReturnShader : IComputeShader<float4>
|
||||
{
|
||||
public float4 Execute()
|
||||
|
||||
@@ -74,6 +74,7 @@ public partial class InitializationTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct SampleShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
|
||||
@@ -30,6 +30,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyBuffer_T1_AsReadOnlyBufferShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyBuffer<float> source;
|
||||
@@ -63,6 +64,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteBuffer_T1_AsReadWriteBufferShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> source;
|
||||
@@ -96,6 +98,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture1D_T1_AsReadOnlyTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<float> source;
|
||||
@@ -129,6 +132,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture1D_T1_AsReadWriteTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture1D<float> source;
|
||||
@@ -166,6 +170,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture1D_T1_AsIReadOnlyTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyTexture1D<float> source;
|
||||
@@ -199,6 +204,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture1D_T2_AsReadOnlyTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<Rgba32, float4> source;
|
||||
@@ -232,6 +238,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture1D_T2_AsIReadOnlyNormalizedTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture1D<float4> source;
|
||||
@@ -265,6 +272,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture1D_T2_AsReadWriteTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture1D<Rgba32, float4> source;
|
||||
@@ -298,6 +306,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture1D_T2_AsIReadWriteNormalizedTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadWriteNormalizedTexture1D<float4> source;
|
||||
@@ -331,6 +340,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture2D_T1_AsReadOnlyTexture2DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<float> source;
|
||||
@@ -365,6 +375,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture2D_T1_AsReadWriteTexture2DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture2D<float> source;
|
||||
@@ -403,6 +414,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture2D_T1_AsIReadOnlyTexture2DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyTexture2D<float> source;
|
||||
@@ -437,6 +449,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture2D_T2_AsReadOnlyTexture2DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<Rgba32, float4> source;
|
||||
@@ -471,6 +484,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture2D_T2_AsIReadOnlyNormalizedTexture2DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture2D<float4> source;
|
||||
@@ -505,6 +519,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture2D_T2_AsReadWriteTexture2DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture2D<Rgba32, float4> source;
|
||||
@@ -539,6 +554,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture2D_T2_AsIReadWriteNormalizedTexture2DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadWriteNormalizedTexture2D<float4> source;
|
||||
@@ -573,6 +589,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture3D_T1_AsReadOnlyTexture3DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<float> source;
|
||||
@@ -608,6 +625,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture3D_T1_AsReadWriteTexture3DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture3D<float> source;
|
||||
@@ -647,6 +665,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture3D_T1_AsIReadOnlyTexture3DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyTexture3D<float> source;
|
||||
@@ -682,6 +701,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture3D_T2_AsReadOnlyTexture3DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<Rgba32, float4> source;
|
||||
@@ -717,6 +737,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture3D_T2_AsIReadOnlyNormalizedTexture3DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture3D<float4> source;
|
||||
@@ -752,6 +773,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture3D_T2_AsReadWriteTexture3DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture3D<Rgba32, float4> source;
|
||||
@@ -787,6 +809,7 @@ public partial class ResourceDimensionsTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture3D_T2_AsIReadWriteNormalizedTexture3DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadWriteNormalizedTexture3D<float4> source;
|
||||
|
||||
@@ -133,6 +133,7 @@ foreach (var pair in typesMap)
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct <#=testMethodName#>Shader : IComputeShader
|
||||
{
|
||||
public readonly <#=shaderResourceType#> source;
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct ReservedKeywordsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> row_major;
|
||||
@@ -55,6 +56,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct ReservedKeywordsInCustomTypesShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> row_major;
|
||||
@@ -83,6 +85,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct ReservedKeywordsFromHlslTypesAndBuiltInValuesShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> fragmentKeyword;
|
||||
@@ -125,6 +128,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct ReservedKeywordsPrecompiledShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> row_major;
|
||||
@@ -162,6 +166,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct SpecialTypeAsReturnTypeShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float2> buffer;
|
||||
@@ -184,6 +189,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct LocalFunctionInExternalMethodsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float2> buffer;
|
||||
@@ -216,6 +222,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct CapturedNestedStructTypeShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
@@ -236,6 +243,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct ExternalStructTypeShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
@@ -258,6 +266,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct OutOfOrderMethodsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
@@ -294,6 +303,7 @@ namespace ComputeSharp.Tests
|
||||
}
|
||||
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct StatelessPixelShader : IComputeShader<float4>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
@@ -305,6 +315,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct LoopWithVarCounterShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
@@ -335,6 +346,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct DoublePrecisionSupportShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<double> buffer;
|
||||
@@ -355,6 +367,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct FieldAccessWithThisExpressionShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
@@ -382,6 +395,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ComputeShaderWithInheritedShaderInterfaceShader : IMyBaseShader
|
||||
{
|
||||
int IMyBaseShader.A => 42;
|
||||
@@ -416,6 +430,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct PixelShaderWithInheritedShaderInterfaceShader : IMyBaseShader<float4>
|
||||
{
|
||||
int IMyBaseShader<float4>.A => 42;
|
||||
@@ -465,6 +480,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct StructInstanceMethodsShader : IComputeShader
|
||||
{
|
||||
public readonly MyStructTypeA a;
|
||||
@@ -499,6 +515,7 @@ namespace ComputeSharp.Tests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct PixelShaderWithScopedParameterInMethodsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
@@ -537,6 +554,7 @@ namespace ExternalNamespace
|
||||
{
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct UserDefinedTypeShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
@@ -32,6 +32,7 @@ public partial class ShaderMembersTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct StaticConstantsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
@@ -72,6 +73,7 @@ public partial class ShaderMembersTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct GlobalVariableShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -107,6 +109,7 @@ public partial class ShaderMembersTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct BoolInstanceFieldsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -171,6 +174,7 @@ public partial class ShaderMembersTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct BoolInstanceFieldInCustomStructShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<Int2AndBoolField> buffer;
|
||||
|
||||
@@ -53,6 +53,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct NanAndInfiniteShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer1;
|
||||
@@ -114,6 +115,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ModAndComparisonOperatorsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
@@ -176,6 +178,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct BitwiseOperatorsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -229,6 +232,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct BooleanOperatorsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -279,6 +283,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ToBooleanConversionIntrinsicsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyBuffer<float> buffer1;
|
||||
@@ -363,6 +368,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct FromBooleanConversionIntrinsicsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyBuffer<int> source;
|
||||
@@ -446,6 +452,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ConstantsInShaderConstantFieldsShader : IComputeShader
|
||||
{
|
||||
public const float rot_angle = (float)(137.2 / 180.0 * Math.PI);
|
||||
@@ -524,6 +531,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct DoubleConstantsInShaderConstantFieldsShader : IComputeShader
|
||||
{
|
||||
public const float DoubleToFloatConstant = (float)(1 / 255.0);
|
||||
@@ -586,6 +594,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct InterlockedOperationsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -631,6 +640,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct GlslStyleMulOperatorsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyBuffer<float> source1;
|
||||
@@ -772,6 +782,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct CustomStructTypeShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<CustomStructType> source;
|
||||
@@ -810,6 +821,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct MiscHlslIntrinsicsShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer1;
|
||||
@@ -853,6 +865,7 @@ public partial class ShaderRewriterTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadonlyModifierInMethodsShader : IComputeShader
|
||||
{
|
||||
private readonly ReadWriteBuffer<int> buffer;
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ColorfulInfinity : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ContouredLayers : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ExtrudedTruchetPattern : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct FourColorGradient : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct FractalTiling : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct HelloWorld : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct MengerJourney : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Octagrams : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ProteanClouds : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct PyramidPattern : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct TerracedHills : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct TriangleGridContouring : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct TwoTiledTruchet : IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -90,6 +90,7 @@ partial class Texture1DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct SamplingComputeShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture1D<float4> source;
|
||||
|
||||
@@ -70,6 +70,7 @@ partial class Texture1DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Bgra32_Float4 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<Bgra32, Float4> source;
|
||||
@@ -83,6 +84,7 @@ partial class Texture1DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_R16_float : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<R16, float> source;
|
||||
@@ -96,6 +98,7 @@ partial class Texture1DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_R8_float : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<R8, float> source;
|
||||
@@ -109,6 +112,7 @@ partial class Texture1DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rg16_Float2 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<Rg16, Float2> source;
|
||||
@@ -122,6 +126,7 @@ partial class Texture1DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rg32_Float2 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<Rg32, Float2> source;
|
||||
@@ -135,6 +140,7 @@ partial class Texture1DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rgba32_Float4 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<Rgba32, Float4> source;
|
||||
@@ -148,6 +154,7 @@ partial class Texture1DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rgba64_Float4 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<Rgba64, Float4> source;
|
||||
|
||||
@@ -66,6 +66,7 @@ foreach (var (t, tPixel) in EnumerateTypes())
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_<#=t#>_<#=tPixel#> : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<<#=t#>, <#=tPixel#>> source;
|
||||
|
||||
@@ -364,6 +364,7 @@ public partial class Texture1DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture1DKernel : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<int> source;
|
||||
@@ -395,6 +396,7 @@ public partial class Texture1DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture1DKernel : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture1D<int> source;
|
||||
|
||||
@@ -73,6 +73,7 @@ partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct SamplingComputeShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture2D<float4> source;
|
||||
@@ -107,6 +108,7 @@ partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
public readonly partial struct SamplingPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture2D<float4> texture;
|
||||
|
||||
@@ -70,6 +70,7 @@ partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Bgra32_Float4 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<Bgra32, Float4> source;
|
||||
@@ -83,6 +84,7 @@ partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_R16_float : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<R16, float> source;
|
||||
@@ -96,6 +98,7 @@ partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_R8_float : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<R8, float> source;
|
||||
@@ -109,6 +112,7 @@ partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rg16_Float2 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<Rg16, Float2> source;
|
||||
@@ -122,6 +126,7 @@ partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rg32_Float2 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<Rg32, Float2> source;
|
||||
@@ -135,6 +140,7 @@ partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rgba32_Float4 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<Rgba32, Float4> source;
|
||||
@@ -148,6 +154,7 @@ partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rgba64_Float4 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<Rgba64, Float4> source;
|
||||
|
||||
@@ -66,6 +66,7 @@ foreach (var (t, tPixel) in EnumerateTypes())
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_<#=t#>_<#=tPixel#> : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<<#=t#>, <#=tPixel#>> source;
|
||||
|
||||
@@ -429,6 +429,7 @@ public partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture2DKernel : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture2D<int> source;
|
||||
@@ -460,6 +461,7 @@ public partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture2DKernel : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture2D<int> source;
|
||||
|
||||
@@ -70,6 +70,7 @@ partial class Texture3DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Bgra32_Float4 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<Bgra32, Float4> source;
|
||||
@@ -83,6 +84,7 @@ partial class Texture3DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_R16_float : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<R16, float> source;
|
||||
@@ -96,6 +98,7 @@ partial class Texture3DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_R8_float : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<R8, float> source;
|
||||
@@ -109,6 +112,7 @@ partial class Texture3DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rg16_Float2 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<Rg16, Float2> source;
|
||||
@@ -122,6 +126,7 @@ partial class Texture3DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rg32_Float2 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<Rg32, Float2> source;
|
||||
@@ -135,6 +140,7 @@ partial class Texture3DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rgba32_Float4 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<Rgba32, Float4> source;
|
||||
@@ -148,6 +154,7 @@ partial class Texture3DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_Rgba64_Float4 : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<Rgba64, Float4> source;
|
||||
|
||||
@@ -66,6 +66,7 @@ foreach (var (t, tPixel) in EnumerateTypes())
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct Shader_Unorm_<#=t#>_<#=tPixel#> : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<<#=t#>, <#=tPixel#>> source;
|
||||
|
||||
@@ -534,6 +534,7 @@ public partial class Texture3DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadOnlyTexture3DKernel : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture3D<int> source;
|
||||
@@ -565,6 +566,7 @@ public partial class Texture3DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ReadWriteTexture3DKernel : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture3D<int> source;
|
||||
|
||||
@@ -29,6 +29,7 @@ public partial class ThreadGroupSizeTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct DispatchXShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -41,6 +42,7 @@ public partial class ThreadGroupSizeTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct DispatchXYShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -53,6 +55,7 @@ public partial class ThreadGroupSizeTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XYZ)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct DispatchXYZShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
@@ -65,6 +68,7 @@ public partial class ThreadGroupSizeTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(11, 14, 6)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct DispatchCustomShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<int> buffer;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする