Merge pull request #619 from Sergio0694/dev/compute-shader-descriptor
Add IComputeShaderDescriptor<T> interface
このコミットが含まれているのは:
59ファイル変更
+464
-405
検索条件に一致するファイルはありません
@@ -8,7 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct ColorfulInfinity : IPixelShader<float4>
|
||||
internal readonly partial struct ColorfulInfinity : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct ContouredLayers : IPixelShader<float4>
|
||||
internal readonly partial struct ContouredLayers : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time Hlsl.Since the start of the application.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
|
||||
internal readonly partial struct ExtrudedTruchetPattern : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct FourColorGradient : IPixelShader<float4>
|
||||
internal readonly partial struct FourColorGradient : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct FractalTiling : IPixelShader<float4>
|
||||
internal readonly partial struct FractalTiling : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct HelloWorld : IPixelShader<float4>
|
||||
internal readonly partial struct HelloWorld : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct MengerJourney : IPixelShader<float4>
|
||||
internal readonly partial struct MengerJourney : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct Octagrams : IPixelShader<float4>
|
||||
internal readonly partial struct Octagrams : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct ProteanClouds : IPixelShader<float4>
|
||||
internal readonly partial struct ProteanClouds : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time Hlsl.Since the start of the application.
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct PyramidPattern : IPixelShader<float4>
|
||||
internal readonly partial struct PyramidPattern : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time Hlsl.Since the start of the application.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct TerracedHills : IPixelShader<float4>
|
||||
internal readonly partial struct TerracedHills : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct TriangleGridContouring : IPixelShader<float4>
|
||||
internal readonly partial struct TriangleGridContouring : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time Hlsl.Since the start of the application.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ComputeSharp.SwapChain.Shaders;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct TwoTiledTruchet : IPixelShader<float4>
|
||||
internal readonly partial struct TwoTiledTruchet : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ComputeSharp.Descriptors;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace ComputeSharp.SwapChain.Backend;
|
||||
@@ -11,7 +12,7 @@ namespace ComputeSharp.SwapChain.Backend;
|
||||
/// The main point of this type is to hide the complexity of <see cref="Win32Application"/> from the non-NativeAOT sample.
|
||||
/// </remarks>
|
||||
internal static class Win32ApplicationFactory<T>
|
||||
where T : struct, IPixelShader<float4>
|
||||
where T : struct, IComputeShader<float4>, IComputeShaderDescriptor<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Func{T1, TResult}"/> instance used to create shaders to run.
|
||||
|
||||
-6
@@ -51,12 +51,6 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
string fieldName = fieldSymbol.Name;
|
||||
string typeName = fieldSymbol.Type.GetFullyQualifiedMetadataName();
|
||||
|
||||
// Disambiguates the name of target fields against the current input parameters
|
||||
if (fieldName is "loader")
|
||||
{
|
||||
fieldName = $"this.{fieldName}";
|
||||
}
|
||||
|
||||
// The first item in each nested struct needs to be aligned to 16 bytes
|
||||
if (isFirstField && fieldPath.Length > 0)
|
||||
{
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the available numeric properties.
|
||||
/// </summary>
|
||||
private static partial class NumericProperties
|
||||
private static class NumericProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the <c>ConstantBufferSize</c> property.
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using ComputeSharp.Descriptors;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using DirectX = TerraFX.Interop.DirectX.DirectX2;
|
||||
#endif
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.Interop;
|
||||
|
||||
/// <summary>
|
||||
@@ -32,7 +30,7 @@ public static class ReflectionServices
|
||||
/// the APIs to dispatch a shader, the thread sizes would actually be set to a proper value insead.
|
||||
/// </remarks>
|
||||
public static ShaderInfo GetShaderInfo<T>()
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
return GetNonGenericShaderInfo(default(T));
|
||||
}
|
||||
@@ -49,7 +47,7 @@ public static class ReflectionServices
|
||||
/// the APIs to dispatch a shader, the thread sizes would actually be set to a proper value insead.
|
||||
/// </remarks>
|
||||
public static unsafe ShaderInfo GetShaderInfo<T>(in T shader)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
return GetNonGenericShaderInfo(in shader);
|
||||
}
|
||||
@@ -70,7 +68,7 @@ public static class ReflectionServices
|
||||
/// the APIs to dispatch a shader, the thread sizes would actually be set to a proper value insead.
|
||||
/// </remarks>
|
||||
public static ShaderInfo GetShaderInfo<T, TPixel>()
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where T : struct, IComputeShader<TPixel>, IComputeShaderDescriptor<T>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
return GetNonGenericShaderInfo(default(T));
|
||||
@@ -89,7 +87,7 @@ public static class ReflectionServices
|
||||
/// the APIs to dispatch a shader, the thread sizes would actually be set to a proper value insead.
|
||||
/// </remarks>
|
||||
public static unsafe ShaderInfo GetShaderInfo<T, TPixel>(in T shader)
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where T : struct, IComputeShader<TPixel>, IComputeShaderDescriptor<T>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
return GetNonGenericShaderInfo(in shader);
|
||||
@@ -102,7 +100,7 @@ public static class ReflectionServices
|
||||
/// <param name="shader">The input shader to retrieve info for.</param>
|
||||
/// <returns>The resulting <see cref="ShaderInfo"/> instance.</returns>
|
||||
private static unsafe ShaderInfo GetNonGenericShaderInfo<T>(in T shader)
|
||||
where T : struct, IShader
|
||||
where T : struct, IComputeShaderDescriptor<T>
|
||||
{
|
||||
string hlslSource = Unsafe.AsRef(in shader).HlslSource;
|
||||
|
||||
|
||||
+12
-8
@@ -5,10 +5,10 @@ using ComputeSharp.SourceGenerators.Models;
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class IShaderGenerator
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class LoadDispatchData
|
||||
partial class DispatchDataLoading
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the <c>LoadConstantBuffer</c> method.
|
||||
@@ -17,10 +17,12 @@ partial class IShaderGenerator
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
public static void WriteLoadConstantBufferSyntax(ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
string typeName = info.Hierarchy.Hierarchy[0].QualifiedName;
|
||||
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine("[global::System.Runtime.CompilerServices.SkipLocalsInit]");
|
||||
writer.WriteLine("readonly void global::ComputeSharp.__Internals.IShader.LoadConstantBuffer<TLoader>(ref TLoader loader, int x, int y, int z)");
|
||||
writer.WriteLine($"readonly void global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{typeName}>.LoadConstantBuffer<TLoader>(in {typeName} shader, ref TLoader loader, int x, int y, int z)");
|
||||
|
||||
using (writer.WriteBlock())
|
||||
{
|
||||
@@ -41,14 +43,14 @@ partial class IShaderGenerator
|
||||
// Read a boolean value and cast it to Bool first, which will apply the correct size expansion
|
||||
writer.WriteLine(
|
||||
$"global::System.Runtime.CompilerServices.Unsafe.As<byte, global::ComputeSharp.Bool>(ref span[{primitive.Offset}]) = " +
|
||||
$"(global::ComputeSharp.Bool){string.Join(".", primitive.FieldPath)};");
|
||||
$"(global::ComputeSharp.Bool)shader.{string.Join(".", primitive.FieldPath)};");
|
||||
break;
|
||||
case FieldInfo.Primitive primitive:
|
||||
|
||||
// Read a primitive value and serialize it into the target buffer
|
||||
writer.WriteLine(
|
||||
$"global::System.Runtime.CompilerServices.Unsafe.As<byte, global::{primitive.TypeName}>(ref span[{primitive.Offset}]) = " +
|
||||
$"{string.Join(".", primitive.FieldPath)};");
|
||||
$"shader.{string.Join(".", primitive.FieldPath)};");
|
||||
break;
|
||||
|
||||
case FieldInfo.NonLinearMatrix matrix:
|
||||
@@ -61,7 +63,7 @@ partial class IShaderGenerator
|
||||
// ref global::System.Runtime.CompilerServices.Unsafe.AsRef(in <FIELD_PATH>));
|
||||
writer.WriteLine(
|
||||
$"ref {rowTypeName} {rowLocalName} = ref global::System.Runtime.CompilerServices.Unsafe.As<global::{matrix.TypeName}, {rowTypeName}>(" +
|
||||
$"ref global::System.Runtime.CompilerServices.Unsafe.AsRef(in {string.Join(".", matrix.FieldPath)}));");
|
||||
$"ref global::System.Runtime.CompilerServices.Unsafe.AsRef(in shader.{string.Join(".", matrix.FieldPath)}));");
|
||||
|
||||
// Generate the loading code for each individual row, with proper alignment.
|
||||
// This will result in the following (assuming Float2x3 m):
|
||||
@@ -92,9 +94,11 @@ partial class IShaderGenerator
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
public static void WriteLoadGraphicsResourcesSyntax(ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
string typeName = info.Hierarchy.Hierarchy[0].QualifiedName;
|
||||
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine("readonly void global::ComputeSharp.__Internals.IShader.LoadGraphicsResources<TLoader>(ref TLoader loader)");
|
||||
writer.WriteLine($"readonly void global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{typeName}>.LoadGraphicsResources<TLoader>(in {typeName} shader, ref TLoader loader)");
|
||||
|
||||
using (writer.WriteBlock())
|
||||
{
|
||||
@@ -103,7 +107,7 @@ partial class IShaderGenerator
|
||||
{
|
||||
if (fieldInfo is FieldInfo.Resource resource)
|
||||
{
|
||||
writer.WriteLine($"loader.LoadGraphicsResource({resource.FieldName}, {resource.Offset});");
|
||||
writer.WriteLine($"loader.LoadGraphicsResource(shader.{resource.FieldName}, {resource.Offset});");
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-9
@@ -15,12 +15,12 @@ using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class IShaderGenerator
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>LoadDispatchData</c> method.
|
||||
/// A helper with all logic to generate the dispatch data loading methods.
|
||||
/// </summary>
|
||||
private static partial class LoadDispatchData
|
||||
private static partial class DispatchDataLoading
|
||||
{
|
||||
/// <summary>
|
||||
/// Explores a given type hierarchy and generates statements to load fields.
|
||||
@@ -56,12 +56,6 @@ partial class IShaderGenerator
|
||||
string fieldName = fieldSymbol.Name;
|
||||
string typeName = fieldSymbol.Type.GetFullyQualifiedMetadataName();
|
||||
|
||||
// Disambiguates the name of target fields against the current input parameters
|
||||
if (fieldName is "loader" or "device" or "x" or "y" or "z")
|
||||
{
|
||||
fieldName = $"this.{fieldName}";
|
||||
}
|
||||
|
||||
// The first item in each nested struct needs to be aligned to 16 bytes
|
||||
if (isFirstField && fieldPath.Length > 0)
|
||||
{
|
||||
+2
-2
@@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis;
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class IShaderGenerator
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets whether a given type is a compute shader type (ie. implements any of the interfaces).
|
||||
@@ -15,7 +15,7 @@ partial class IShaderGenerator
|
||||
private static bool TryGetIsPixelShaderLike(INamedTypeSymbol typeSymbol, Compilation compilation, out bool result)
|
||||
{
|
||||
INamedTypeSymbol computeShaderSymbol = compilation.GetTypeByMetadataName("ComputeSharp.IComputeShader")!;
|
||||
INamedTypeSymbol pixelShaderSymbol = compilation.GetTypeByMetadataName("ComputeSharp.IPixelShader`1")!;
|
||||
INamedTypeSymbol pixelShaderSymbol = compilation.GetTypeByMetadataName("ComputeSharp.IComputeShader`1")!;
|
||||
|
||||
foreach (INamedTypeSymbol interfaceSymbol in typeSymbol.AllInterfaces)
|
||||
{
|
||||
+6
-6
@@ -6,10 +6,10 @@ using ComputeSharp.SourceGenerators.Models;
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class IShaderGenerator
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class LoadBytecode
|
||||
partial class HlslBytecode
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the <c>HlslBytecode</c> property.
|
||||
@@ -20,7 +20,7 @@ partial class IShaderGenerator
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.Write($"readonly global::System.ReadOnlyMemory<byte> global::ComputeSharp.__Internals.IShader.HlslBytecode => ");
|
||||
writer.Write($"readonly global::System.ReadOnlyMemory<byte> global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.HlslBytecode => ");
|
||||
|
||||
// Just like with the D2D1 generator, only return the MemoryManager<T> if we do have HLSL bytecode
|
||||
if (info.HlslInfo is not HlslBytecodeInfo.Success)
|
||||
@@ -129,7 +129,7 @@ partial class IShaderGenerator
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.__Internals.IShader.ThreadsX => {info.ThreadsX};");
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ThreadsX => {info.ThreadsX};");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -141,7 +141,7 @@ partial class IShaderGenerator
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.__Internals.IShader.ThreadsY => {info.ThreadsY};");
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ThreadsY => {info.ThreadsY};");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -153,7 +153,7 @@ partial class IShaderGenerator
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.__Internals.IShader.ThreadsZ => {info.ThreadsZ};");
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ThreadsZ => {info.ThreadsZ};");
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-88
@@ -22,12 +22,12 @@ using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class IShaderGenerator
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>LoadBytecode</c> method.
|
||||
/// A helper with all logic to generate the <c>HlslBytecode</c> property.
|
||||
/// </summary>
|
||||
private static partial class LoadBytecode
|
||||
private static partial class HlslBytecode
|
||||
{
|
||||
/// <summary>
|
||||
/// The shared cache of <see cref="HlslBytecodeInfo"/> values.
|
||||
@@ -39,91 +39,6 @@ partial class IShaderGenerator
|
||||
/// </summary>
|
||||
private static volatile bool areDxcLibrariesLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the thread ids values for a given shader type, if available.
|
||||
/// </summary>
|
||||
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
|
||||
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
|
||||
/// <param name="threadsX">The thread ids value for the X axis.</param>
|
||||
/// <param name="threadsY">The thread ids value for the Y axis.</param>
|
||||
/// <param name="threadsZ">The thread ids value for the Z axis.</param>
|
||||
/// <param name="isCompilationEnabled">Whether compilation should be attempted for the current info.</param>
|
||||
public static void GetInfo(
|
||||
ImmutableArrayBuilder<DiagnosticInfo> diagnostics,
|
||||
INamedTypeSymbol structDeclarationSymbol,
|
||||
out int threadsX,
|
||||
out int threadsY,
|
||||
out int threadsZ,
|
||||
out bool isCompilationEnabled)
|
||||
{
|
||||
// Try to get the attribute that controls shader precompilation (has to be present when ComputeSharp.Dynamic is not referenced)
|
||||
if (!structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName(typeof(EmbeddedBytecodeAttribute).FullName, out AttributeData? attribute))
|
||||
{
|
||||
// Emit the diagnostics if dynamic shaders are not supported
|
||||
diagnostics.Add(MissingEmbeddedBytecodeAttributeWhenDynamicShaderCompilationIsNotSupported, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
threadsX = threadsY = threadsZ = 0;
|
||||
isCompilationEnabled = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for a dispatch axis argument first
|
||||
if (attribute.ConstructorArguments.Length == 1)
|
||||
{
|
||||
int dispatchAxis = (int)attribute.ConstructorArguments[0].Value!;
|
||||
|
||||
(threadsX, threadsY, threadsZ) = (DispatchAxis)dispatchAxis switch
|
||||
{
|
||||
DispatchAxis.X => (64, 1, 1),
|
||||
DispatchAxis.Y => (1, 64, 1),
|
||||
DispatchAxis.Z => (1, 1, 64),
|
||||
DispatchAxis.XY => (8, 8, 1),
|
||||
DispatchAxis.XZ => (8, 1, 8),
|
||||
DispatchAxis.YZ => (1, 8, 8),
|
||||
DispatchAxis.XYZ => (4, 4, 4),
|
||||
_ => (0, 0, 0)
|
||||
};
|
||||
|
||||
// Validate the dispatch axis argument
|
||||
if ((threadsX, threadsY, threadsZ) is (0, 0, 0))
|
||||
{
|
||||
diagnostics.Add(InvalidEmbeddedBytecodeDispatchAxis, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
threadsX = threadsY = threadsZ = 0;
|
||||
isCompilationEnabled = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
isCompilationEnabled = true;
|
||||
}
|
||||
else if (
|
||||
attribute.ConstructorArguments.Length != 3 ||
|
||||
attribute.ConstructorArguments[0].Value is not int explicitThreadsX ||
|
||||
attribute.ConstructorArguments[1].Value is not int explicitThreadsY ||
|
||||
attribute.ConstructorArguments[2].Value is not int explicitThreadsZ ||
|
||||
explicitThreadsX is < 1 or > 1024 ||
|
||||
explicitThreadsY is < 1 or > 1024 ||
|
||||
explicitThreadsZ is < 1 or > 64)
|
||||
{
|
||||
// Failed to validate the thread number arguments
|
||||
diagnostics.Add(InvalidEmbeddedBytecodeThreadIds, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
threadsX = threadsY = threadsZ = 0;
|
||||
isCompilationEnabled = false;
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
threadsX = explicitThreadsX;
|
||||
threadsY = explicitThreadsY;
|
||||
threadsZ = explicitThreadsZ;
|
||||
isCompilationEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="HlslBytecodeInfo"/> instance for the input shader info.
|
||||
/// </summary>
|
||||
+4
-4
@@ -5,13 +5,13 @@ using ComputeSharp.SourceGenerators.Models;
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class IShaderGenerator
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class BuildHlslSource
|
||||
partial class HlslSource
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the <c>BuildHlslSource</c> method.
|
||||
/// Writes the <c>HlslSource</c> property.
|
||||
/// </summary>
|
||||
/// <param name="info">The input <see cref="ShaderInfo"/> instance with gathered shader info.</param>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
@@ -19,7 +19,7 @@ partial class IShaderGenerator
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly string global::ComputeSharp.__Internals.IShader.HlslSource =>");
|
||||
writer.WriteLine($"readonly string global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.HlslSource =>");
|
||||
writer.IncreaseIndent();
|
||||
writer.WriteLine("\"\"\"");
|
||||
writer.Write(info.HlslInfoKey.HlslSource, isMultiline: true);
|
||||
+6
-6
@@ -17,12 +17,12 @@ using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class IShaderGenerator
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>BuildHlslSource</c> method.
|
||||
/// A helper with all logic to generate the <c>HlslSource</c> property.
|
||||
/// </summary>
|
||||
internal static partial class BuildHlslSource
|
||||
internal static partial class HlslSource
|
||||
{
|
||||
/// <summary>
|
||||
/// Gathers all necessary information on a transpiled HLSL source for a given shader type.
|
||||
@@ -59,14 +59,14 @@ partial class IShaderGenerator
|
||||
Dictionary<IFieldSymbol, string> constantDefinitions = new(SymbolEqualityComparer.Default);
|
||||
|
||||
// A given type can only represent a single shader type
|
||||
if (structDeclarationSymbol.AllInterfaces.Count(static interfaceSymbol => interfaceSymbol is { Name: nameof(IComputeShader) } or { IsGenericType: true, Name: nameof(IPixelShader<byte>) }) > 1)
|
||||
if (structDeclarationSymbol.AllInterfaces.Count(static interfaceSymbol => interfaceSymbol is { Name: nameof(IComputeShader) } or { IsGenericType: true, Name: nameof(IComputeShader<byte>) }) > 1)
|
||||
{
|
||||
diagnostics.Add(MultipleShaderTypesImplemented, structDeclarationSymbol, structDeclarationSymbol);
|
||||
}
|
||||
|
||||
// Explore the syntax tree and extract the processed info
|
||||
SemanticModelProvider semanticModelProvider = new(compilation);
|
||||
INamedTypeSymbol? pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: nameof(IPixelShader<byte>) });
|
||||
INamedTypeSymbol? pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: nameof(IComputeShader<byte>) });
|
||||
bool isComputeShader = pixelShaderSymbol is null;
|
||||
string? implicitTextureType = isComputeShader ? null : HlslKnownTypes.GetMappedNameForPixelShaderType(pixelShaderSymbol!);
|
||||
(ImmutableArray<(string MetadataName, string Name, string HlslType)> resourceFields, ImmutableArray<(string Name, string HlslType)> valueFields) = GetInstanceFields(diagnostics, structDeclarationSymbol, discoveredTypes, isComputeShader);
|
||||
@@ -364,7 +364,7 @@ partial class IShaderGenerator
|
||||
methodDeclarationSymbol.TypeParameters.Length == 0 &&
|
||||
methodDeclarationSymbol.Parameters.Length == 0) ||
|
||||
(!isComputeShader &&
|
||||
methodDeclarationSymbol.Name == nameof(IPixelShader<byte>.Execute) &&
|
||||
methodDeclarationSymbol.Name == nameof(IComputeShader<byte>.Execute) &&
|
||||
methodDeclarationSymbol.ReturnType is not null && // TODO: match for pixel type
|
||||
methodDeclarationSymbol.TypeParameters.Length == 0 &&
|
||||
methodDeclarationSymbol.Parameters.Length == 0);
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate additional metadata properties
|
||||
/// </summary>
|
||||
private static class MetadataProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the <c>ConstantBufferSize</c> property.
|
||||
/// </summary>
|
||||
/// <param name="info">The input <see cref="ShaderInfo"/> instance with gathered shader info.</param>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
public static void WriteConstantBufferSizeSyntax(ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ConstantBufferSize => {info.ConstantBufferSizeInBytes};");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the <c>IsStaticSamplerRequired</c> property.
|
||||
/// </summary>
|
||||
/// <param name="info">The input <see cref="ShaderInfo"/> instance with gathered shader info.</param>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
public static void WriteIsStaticSamplerRequiredSyntax(ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly bool global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.IsStaticSamplerRequired => {info.IsSamplerUsed.ToString().ToLowerInvariant()};");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class NumThreads
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the <c>ThreadsX</c> property.
|
||||
/// </summary>
|
||||
/// <param name="info">The input <see cref="ShaderInfo"/> instance with gathered shader info.</param>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
public static void WriteThreadsXSyntax(ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ThreadsX => {info.ThreadsX};");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the <c>ThreadsY</c> property.
|
||||
/// </summary>
|
||||
/// <param name="info">The input <see cref="ShaderInfo"/> instance with gathered shader info.</param>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
public static void WriteThreadsYSyntax(ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ThreadsY => {info.ThreadsY};");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the <c>ThreadsZ</c> property.
|
||||
/// </summary>
|
||||
/// <param name="info">The input <see cref="ShaderInfo"/> instance with gathered shader info.</param>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
public static void WriteThreadsZSyntax(ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ThreadsZ => {info.ThreadsZ};");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>[numthreads]</c> properties.
|
||||
/// </summary>
|
||||
private static partial class NumThreads
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the thread ids values for a given shader type, if available.
|
||||
/// </summary>
|
||||
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
|
||||
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
|
||||
/// <param name="threadsX">The thread ids value for the X axis.</param>
|
||||
/// <param name="threadsY">The thread ids value for the Y axis.</param>
|
||||
/// <param name="threadsZ">The thread ids value for the Z axis.</param>
|
||||
/// <param name="isCompilationEnabled">Whether compilation should be attempted for the current info.</param>
|
||||
public static void GetInfo(
|
||||
ImmutableArrayBuilder<DiagnosticInfo> diagnostics,
|
||||
INamedTypeSymbol structDeclarationSymbol,
|
||||
out int threadsX,
|
||||
out int threadsY,
|
||||
out int threadsZ,
|
||||
out bool isCompilationEnabled)
|
||||
{
|
||||
// Try to get the attribute that controls shader precompilation (has to be present when ComputeSharp.Dynamic is not referenced)
|
||||
if (!structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName(typeof(EmbeddedBytecodeAttribute).FullName, out AttributeData? attribute))
|
||||
{
|
||||
// Emit the diagnostics if dynamic shaders are not supported
|
||||
diagnostics.Add(MissingEmbeddedBytecodeAttributeWhenDynamicShaderCompilationIsNotSupported, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
threadsX = threadsY = threadsZ = 0;
|
||||
isCompilationEnabled = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for a dispatch axis argument first
|
||||
if (attribute.ConstructorArguments.Length == 1)
|
||||
{
|
||||
int dispatchAxis = (int)attribute.ConstructorArguments[0].Value!;
|
||||
|
||||
(threadsX, threadsY, threadsZ) = (DispatchAxis)dispatchAxis switch
|
||||
{
|
||||
DispatchAxis.X => (64, 1, 1),
|
||||
DispatchAxis.Y => (1, 64, 1),
|
||||
DispatchAxis.Z => (1, 1, 64),
|
||||
DispatchAxis.XY => (8, 8, 1),
|
||||
DispatchAxis.XZ => (8, 1, 8),
|
||||
DispatchAxis.YZ => (1, 8, 8),
|
||||
DispatchAxis.XYZ => (4, 4, 4),
|
||||
_ => (0, 0, 0)
|
||||
};
|
||||
|
||||
// Validate the dispatch axis argument
|
||||
if ((threadsX, threadsY, threadsZ) is (0, 0, 0))
|
||||
{
|
||||
diagnostics.Add(InvalidEmbeddedBytecodeDispatchAxis, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
threadsX = threadsY = threadsZ = 0;
|
||||
isCompilationEnabled = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
isCompilationEnabled = true;
|
||||
}
|
||||
else if (
|
||||
attribute.ConstructorArguments.Length != 3 ||
|
||||
attribute.ConstructorArguments[0].Value is not int explicitThreadsX ||
|
||||
attribute.ConstructorArguments[1].Value is not int explicitThreadsY ||
|
||||
attribute.ConstructorArguments[2].Value is not int explicitThreadsZ ||
|
||||
explicitThreadsX is < 1 or > 1024 ||
|
||||
explicitThreadsY is < 1 or > 1024 ||
|
||||
explicitThreadsZ is < 1 or > 64)
|
||||
{
|
||||
// Failed to validate the thread number arguments
|
||||
diagnostics.Add(InvalidEmbeddedBytecodeThreadIds, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
threadsX = threadsY = threadsZ = 0;
|
||||
isCompilationEnabled = false;
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
threadsX = explicitThreadsX;
|
||||
threadsY = explicitThreadsY;
|
||||
threadsZ = explicitThreadsZ;
|
||||
isCompilationEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-27
@@ -5,35 +5,11 @@ using ComputeSharp.SourceGenerators.Models;
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class IShaderGenerator
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
partial class LoadDispatchMetadata
|
||||
partial class ResourceDescriptorRanges
|
||||
{
|
||||
/// <summary>
|
||||
/// Writes the <c>ConstantBufferSize</c> property.
|
||||
/// </summary>
|
||||
/// <param name="info">The input <see cref="ShaderInfo"/> instance with gathered shader info.</param>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
public static void WriteConstantBufferSizeSyntax(ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly int global::ComputeSharp.__Internals.IShader.ConstantBufferSize => {info.ConstantBufferSizeInBytes};");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the <c>IsStaticSamplerRequired</c> property.
|
||||
/// </summary>
|
||||
/// <param name="info">The input <see cref="ShaderInfo"/> instance with gathered shader info.</param>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
public static void WriteIsStaticSamplerRequiredSyntax(ShaderInfo info, IndentedTextWriter writer)
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.WriteLine($"readonly bool global::ComputeSharp.__Internals.IShader.IsStaticSamplerRequired => {info.IsSamplerUsed.ToString().ToLowerInvariant()};");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the <c>ResourceDescriptorRanges</c> property.
|
||||
/// </summary>
|
||||
@@ -43,7 +19,7 @@ partial class IShaderGenerator
|
||||
{
|
||||
writer.WriteLine("/// <inheritdoc/>");
|
||||
writer.WriteGeneratedAttributes(GeneratorName);
|
||||
writer.Write($"readonly global::System.ReadOnlyMemory<global::ComputeSharp.Interop.ResourceDescriptorRange> global::ComputeSharp.__Internals.IShader.ResourceDescriptorRanges => ");
|
||||
writer.Write($"readonly global::System.ReadOnlyMemory<global::ComputeSharp.Interop.ResourceDescriptorRange> global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{info.Hierarchy.Hierarchy[0].QualifiedName}>.ResourceDescriptorRanges => ");
|
||||
|
||||
// If there are no declared resources, just return an empty collection
|
||||
if (info.ResourceDescriptors.IsEmpty)
|
||||
+3
-3
@@ -6,12 +6,12 @@ using ComputeSharp.SourceGenerators.Models;
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial class IShaderGenerator
|
||||
partial class ComputeShaderDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// A helper with all logic to generate the <c>LoadDispatchMetadata</c> method.
|
||||
/// A helper with all logic to generate the <c>ResourceDescriptorRanges</c> property.
|
||||
/// </summary>
|
||||
private static partial class LoadDispatchMetadata
|
||||
private static partial class ResourceDescriptorRanges
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the data related to the shader metadata for a given shader type.
|
||||
+26
-27
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
@@ -12,15 +11,15 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
namespace ComputeSharp.SourceGenerators;
|
||||
|
||||
/// <summary>
|
||||
/// A source generator creating data loaders for <see cref="IComputeShader"/> and <see cref="IPixelShader{TPixel}"/> types.
|
||||
/// A source generator creating descriptors for <see cref="IComputeShader"/> and <see cref="IComputeShader{TPixel}"/> types.
|
||||
/// </summary>
|
||||
[Generator(LanguageNames.CSharp)]
|
||||
public sealed partial class IShaderGenerator : IIncrementalGenerator
|
||||
public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of generator to include in the generated code.
|
||||
/// </summary>
|
||||
private const string GeneratorName = "ComputeSharp.IShaderGenerator";
|
||||
private const string GeneratorName = "ComputeSharp.ComputeShaderDescriptorGenerator";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||
@@ -54,8 +53,8 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
|
||||
|
||||
using ImmutableArrayBuilder<DiagnosticInfo> diagnostics = new();
|
||||
|
||||
// LoadDispatchData() info
|
||||
ImmutableArray<FieldInfo> fieldInfos = LoadDispatchData.GetInfo(
|
||||
// Dispatch data loading info
|
||||
ImmutableArray<FieldInfo> fieldInfos = DispatchDataLoading.GetInfo(
|
||||
diagnostics,
|
||||
typeSymbol,
|
||||
isPixelShaderLike,
|
||||
@@ -64,8 +63,8 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
// TryGetBytecode() info
|
||||
LoadBytecode.GetInfo(
|
||||
// Thread group size info
|
||||
NumThreads.GetInfo(
|
||||
diagnostics,
|
||||
typeSymbol,
|
||||
out int threadsX,
|
||||
@@ -75,8 +74,8 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
// BuildHlslSource() info
|
||||
BuildHlslSource.GetInfo(
|
||||
// Transpiled HLSL source info
|
||||
HlslSource.GetInfo(
|
||||
diagnostics,
|
||||
context.SemanticModel.Compilation,
|
||||
typeDeclaration,
|
||||
@@ -90,8 +89,8 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
// GetDispatchMetadata() info
|
||||
ImmutableArray<ResourceDescriptor> resourceDescriptors = LoadDispatchMetadata.GetInfo(
|
||||
// Resource descriptor ranges info
|
||||
ImmutableArray<ResourceDescriptor> resourceDescriptors = ResourceDescriptorRanges.GetInfo(
|
||||
isImplicitTextureUsed,
|
||||
isSamplerUsed,
|
||||
fieldInfos);
|
||||
@@ -102,11 +101,11 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
|
||||
HlslBytecodeInfoKey hlslInfoKey = new(hlslSource, isCompilationEnabled);
|
||||
|
||||
// Try to get the HLSL bytecode
|
||||
HlslBytecodeInfo hlslInfo = LoadBytecode.GetBytecode(ref hlslInfoKey, token);
|
||||
HlslBytecodeInfo hlslInfo = HlslBytecode.GetBytecode(ref hlslInfoKey, token);
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
LoadBytecode.GetInfoDiagnostics(typeSymbol, hlslInfo, diagnostics);
|
||||
HlslBytecode.GetInfoDiagnostics(typeSymbol, hlslInfo, diagnostics);
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -144,29 +143,29 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
|
||||
{
|
||||
using ImmutableArrayBuilder<IndentedTextWriter.Callback<ShaderInfo>> declaredMembers = new();
|
||||
|
||||
declaredMembers.Add(LoadBytecode.WriteThreadsXSyntax);
|
||||
declaredMembers.Add(LoadBytecode.WriteThreadsYSyntax);
|
||||
declaredMembers.Add(LoadBytecode.WriteThreadsZSyntax);
|
||||
declaredMembers.Add(LoadDispatchMetadata.WriteConstantBufferSizeSyntax);
|
||||
declaredMembers.Add(LoadDispatchMetadata.WriteIsStaticSamplerRequiredSyntax);
|
||||
declaredMembers.Add(LoadDispatchMetadata.WriteSyntax);
|
||||
declaredMembers.Add(BuildHlslSource.WriteSyntax);
|
||||
declaredMembers.Add(LoadBytecode.WriteHlslBytecodeSyntax);
|
||||
declaredMembers.Add(LoadDispatchData.WriteLoadConstantBufferSyntax);
|
||||
declaredMembers.Add(LoadDispatchData.WriteLoadGraphicsResourcesSyntax);
|
||||
declaredMembers.Add(HlslBytecode.WriteThreadsXSyntax);
|
||||
declaredMembers.Add(HlslBytecode.WriteThreadsYSyntax);
|
||||
declaredMembers.Add(HlslBytecode.WriteThreadsZSyntax);
|
||||
declaredMembers.Add(MetadataProperties.WriteConstantBufferSizeSyntax);
|
||||
declaredMembers.Add(MetadataProperties.WriteIsStaticSamplerRequiredSyntax);
|
||||
declaredMembers.Add(ResourceDescriptorRanges.WriteSyntax);
|
||||
declaredMembers.Add(HlslSource.WriteSyntax);
|
||||
declaredMembers.Add(HlslBytecode.WriteHlslBytecodeSyntax);
|
||||
declaredMembers.Add(DispatchDataLoading.WriteLoadConstantBufferSyntax);
|
||||
declaredMembers.Add(DispatchDataLoading.WriteLoadGraphicsResourcesSyntax);
|
||||
|
||||
using ImmutableArrayBuilder<IndentedTextWriter.Callback<ShaderInfo>> additionalTypes = new();
|
||||
using ImmutableHashSetBuilder<string> usingDirectives = new();
|
||||
|
||||
LoadDispatchMetadata.RegisterAdditionalDataMemberSyntax(item, additionalTypes, usingDirectives);
|
||||
LoadBytecode.RegisterAdditionalTypeSyntax(item, additionalTypes, usingDirectives);
|
||||
ResourceDescriptorRanges.RegisterAdditionalDataMemberSyntax(item, additionalTypes, usingDirectives);
|
||||
HlslBytecode.RegisterAdditionalTypeSyntax(item, additionalTypes, usingDirectives);
|
||||
|
||||
using IndentedTextWriter writer = new();
|
||||
|
||||
item.Hierarchy.WriteSyntax(
|
||||
state: item,
|
||||
writer: writer,
|
||||
baseTypes: ReadOnlySpan<string>.Empty,
|
||||
baseTypes: new[] { $"global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{item.Hierarchy.Hierarchy[0].QualifiedName}>" },
|
||||
memberCallbacks: declaredMembers.WrittenSpan);
|
||||
|
||||
// Append any additional types as well
|
||||
@@ -66,7 +66,7 @@
|
||||
<Compile Include="..\ComputeSharp\Core\Dispatch\ThreadIds.Normalized.cs" Link="ComputeSharp\Core\Dispatch\ThreadIds.Normalized.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Helpers\AlignmentHelper.cs" Link="ComputeSharp\Core\Helpers\AlignmentHelper.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Interfaces\IComputeShader.cs" Link="ComputeSharp\Core\Interfaces\IComputeShader.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Interfaces\IPixelShader{TPixel}.cs" Link="ComputeSharp\Core\Interfaces\IPixelShader{TPixel}.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Interfaces\IComputeShader{TPixel}.cs" Link="ComputeSharp\Core\Interfaces\IComputeShader{TPixel}.cs" />
|
||||
<Compile Include="..\ComputeSharp\Graphics\Extensions\Interop\ComPtrExtensions.cs" Link="ComputeSharp\Graphics\Extensions\Interop\ComPtrExtensions.cs" />
|
||||
<Compile Include="..\ComputeSharp.Dynamic\Shaders\Exceptions\DxcCompilationException.cs" Link="ComputeSharp\Shaders\Exceptions\DxcCompilationException.cs" />
|
||||
<Compile Include="..\ComputeSharp.Dynamic\Shaders\Translation\ShaderCompiler.cs" Link="ComputeSharp\Shaders\Translation\ShaderCompiler.cs" />
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ComputeSharp.__Internals;
|
||||
|
||||
/// <summary>
|
||||
/// A base <see langword="interface"/> representing a given shader that can be dispatched.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This interface is not intended to be used directly by user code")]
|
||||
public interface IShader
|
||||
{
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ComputeSharp.Descriptors;
|
||||
|
||||
namespace ComputeSharp.WinUI;
|
||||
|
||||
@@ -8,7 +9,7 @@ namespace ComputeSharp.WinUI;
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of shader to use to render frames.</typeparam>
|
||||
public sealed class ShaderRunner<T> : IShaderRunner
|
||||
where T : struct, IPixelShader<Float4>
|
||||
where T : struct, IComputeShader<Float4>, IComputeShaderDescriptor<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Func{T1,TResult}"/> instance used to create shaders to run.
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace ComputeSharp;
|
||||
/// <code>
|
||||
/// // A pixel shader that is dispatched on a target texture
|
||||
/// [EmbeddedBytecode(DispatchAxis.XY)]
|
||||
/// struct MyShader : IPixelShader<float4>
|
||||
/// struct MyShader : IComputeShader<float4>
|
||||
/// {
|
||||
/// }
|
||||
/// </code>
|
||||
|
||||
+11
-8
@@ -1,15 +1,16 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using ComputeSharp.Interop;
|
||||
|
||||
namespace ComputeSharp.__Internals;
|
||||
namespace ComputeSharp.Descriptors;
|
||||
|
||||
/// <summary>
|
||||
/// A base <see langword="interface"/> representing a given shader that can be dispatched.
|
||||
/// An interface for a descriptor for a given compute shader.
|
||||
/// Descriptors contain metadata associated to compute shaders,
|
||||
/// with all information needed to execute them at runtime.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This interface is not intended to be used directly by user code")]
|
||||
public interface IShader
|
||||
/// <typeparam name="T">The type of compute shader being described.</typeparam>
|
||||
public interface IComputeShaderDescriptor<T>
|
||||
where T : struct
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of threads in each thread group for the X axis.
|
||||
@@ -63,18 +64,20 @@ public interface IShader
|
||||
/// Loads the constant buffer of a given input shader.
|
||||
/// </summary>
|
||||
/// <typeparam name="TLoader">The type of data loader being used.</typeparam>
|
||||
/// <param name="shader">The input shader to load the constant buffer for.</param>
|
||||
/// <param name="loader">The <typeparamref name="TLoader"/> instance to use to load the data.</param>
|
||||
/// <param name="x">The number of iterations to run on the X axis.</param>
|
||||
/// <param name="y">The number of iterations to run on the Y axis.</param>
|
||||
/// <param name="z">The number of iterations to run on the Z axis.</param>
|
||||
void LoadConstantBuffer<TLoader>(ref TLoader loader, int x, int y, int z)
|
||||
void LoadConstantBuffer<TLoader>(in T shader, ref TLoader loader, int x, int y, int z)
|
||||
where TLoader : struct, IConstantBufferLoader;
|
||||
|
||||
/// <summary>
|
||||
/// Loads the graphics resources for the shader.
|
||||
/// </summary>
|
||||
/// <typeparam name="TLoader">The type of graphics resource loader being used.</typeparam>
|
||||
/// <param name="shader">The input shader to load the graphics resources for.</param>
|
||||
/// <param name="loader">The <typeparamref name="TLoader"/> instance to use to load the data.</param>
|
||||
void LoadGraphicsResources<TLoader>(ref TLoader loader)
|
||||
void LoadGraphicsResources<TLoader>(in T shader, ref TLoader loader)
|
||||
where TLoader : struct, IGraphicsResourceLoader;
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.__Internals;
|
||||
namespace ComputeSharp.Descriptors;
|
||||
|
||||
/// <summary>
|
||||
/// A type representing a data loader for the constant buffer of a compute shader.
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.__Internals;
|
||||
namespace ComputeSharp.Descriptors;
|
||||
|
||||
/// <summary>
|
||||
/// A type representing a loader object for <see cref="IGraphicsResource"/> values used in compute shaders.
|
||||
@@ -1,13 +1,9 @@
|
||||
using ComputeSharp.__Internals;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// An <see langword="interface"/> representing a compute shader.
|
||||
/// </summary>
|
||||
public interface IComputeShader : IShader
|
||||
public interface IComputeShader
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes the current compute shader.
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// An <see langword="interface"/> representing a compute shader writing into a target texture.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The type of pixels being written by the compute shader.</typeparam>
|
||||
/// <remarks>
|
||||
/// This interface allows implementing logic analogous of pixel shaders, but via compute shaders.
|
||||
/// </remarks>
|
||||
public interface IComputeShader<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes the current compute shader.
|
||||
/// </summary>
|
||||
/// <returns>The pixel value for the current invocation.</returns>
|
||||
TPixel Execute();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using ComputeSharp.__Internals;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// An <see langword="interface"/> representing a pixel shader.
|
||||
/// </summary>
|
||||
public interface IPixelShader<TPixel> : IShader
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes the current pixel shader.
|
||||
/// </summary>
|
||||
/// <returns>The pixel value for the current invocation.</returns>
|
||||
TPixel Execute();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Descriptors;
|
||||
using ComputeSharp.Interop;
|
||||
|
||||
namespace ComputeSharp;
|
||||
@@ -17,7 +18,7 @@ public static partial class GraphicsDeviceExtensions
|
||||
/// <param name="x">The number of iterations to run on the X axis.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run.</param>
|
||||
public static void For<T>(this GraphicsDevice device, int x, in T shader)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
@@ -35,7 +36,7 @@ public static partial class GraphicsDeviceExtensions
|
||||
/// <param name="y">The number of iterations to run on the Y axis.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run.</param>
|
||||
public static void For<T>(this GraphicsDevice device, int x, int y, in T shader)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
@@ -54,7 +55,7 @@ public static partial class GraphicsDeviceExtensions
|
||||
/// <param name="z">The number of iterations to run on the Z axis.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run.</param>
|
||||
public static void For<T>(this GraphicsDevice device, int x, int y, int z, in T shader)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
@@ -71,7 +72,7 @@ public static partial class GraphicsDeviceExtensions
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> to use to run the shader.</param>
|
||||
/// <param name="texture">The target texture to apply the pixel shader to.</param>
|
||||
public static void ForEach<T, TPixel>(this GraphicsDevice device, IReadWriteNormalizedTexture2D<TPixel> texture)
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where T : struct, IComputeShader<TPixel>, IComputeShaderDescriptor<T>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
@@ -91,7 +92,7 @@ public static partial class GraphicsDeviceExtensions
|
||||
/// <param name="texture">The target texture to apply the pixel shader to.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the pixel shader to run.</param>
|
||||
public static void ForEach<T, TPixel>(this GraphicsDevice device, IReadWriteNormalizedTexture2D<TPixel> texture, in T shader)
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where T : struct, IComputeShader<TPixel>, IComputeShaderDescriptor<T>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(device);
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using ComputeSharp.Descriptors;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
@@ -9,8 +10,6 @@ using ComputeSharp.Shaders.Dispatching;
|
||||
using ComputeSharp.Shaders.Loading;
|
||||
using TerraFX.Interop.DirectX;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
@@ -123,7 +122,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
/// <param name="x">The number of iterations to run on the X axis.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run.</param>
|
||||
internal readonly unsafe void Run<T>(int x, ref T shader)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
|
||||
Run(x, 1, 1, ref shader);
|
||||
@@ -136,7 +135,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
/// <param name="y">The number of iterations to run on the Y axis.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run.</param>
|
||||
internal readonly unsafe void Run<T>(int x, int y, ref T shader)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
|
||||
Run(x, y, 1, ref shader);
|
||||
@@ -151,7 +150,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
/// <param name="z">The number of iterations to run on the Z axis.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run.</param>
|
||||
internal readonly unsafe void Run<T>(int x, int y, int z, ref T shader)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
default(ArgumentOutOfRangeException).ThrowIfNegativeOrZero(x);
|
||||
@@ -174,11 +173,11 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
|
||||
D3D12GraphicsCommandListConstantBufferLoader dataLoader = new(commandList.D3D12GraphicsCommandList);
|
||||
|
||||
shader.LoadConstantBuffer(ref dataLoader, x, y, z);
|
||||
shader.LoadConstantBuffer(in shader, ref dataLoader, x, y, z);
|
||||
|
||||
D3D12GraphicsCommandListGraphicsResourceLoader graphicsResourceLoader = new(commandList.D3D12GraphicsCommandList, this.device, rootParameterOffset: 1);
|
||||
|
||||
shader.LoadGraphicsResources(ref graphicsResourceLoader);
|
||||
shader.LoadGraphicsResources(in shader, ref graphicsResourceLoader);
|
||||
|
||||
commandList.D3D12GraphicsCommandList->Dispatch((uint)groupsX, (uint)groupsY, (uint)groupsZ);
|
||||
}
|
||||
@@ -191,7 +190,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
/// <param name="texture">The target texture to invoke the pixel shader upon.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the pixel shader to run.</param>
|
||||
internal readonly unsafe void Run<T, TPixel>(IReadWriteNormalizedTexture2D<TPixel> texture, ref T shader)
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where T : struct, IComputeShader<TPixel>, IComputeShaderDescriptor<T>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(InvalidOperationException).ThrowIf(this.device is null);
|
||||
@@ -212,11 +211,11 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
|
||||
D3D12GraphicsCommandListConstantBufferLoader constantBufferLoader = new(commandList.D3D12GraphicsCommandList);
|
||||
|
||||
shader.LoadConstantBuffer(ref constantBufferLoader, x, y, 1);
|
||||
shader.LoadConstantBuffer(in shader, ref constantBufferLoader, x, y, 1);
|
||||
|
||||
D3D12GraphicsCommandListGraphicsResourceLoader graphicsResourceLoader = new(commandList.D3D12GraphicsCommandList, this.device, rootParameterOffset: 2);
|
||||
|
||||
shader.LoadGraphicsResources(ref graphicsResourceLoader);
|
||||
shader.LoadGraphicsResources(in shader, ref graphicsResourceLoader);
|
||||
|
||||
// Load the implicit output texture
|
||||
commandList.D3D12GraphicsCommandList->SetComputeRootDescriptorTable(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Descriptors;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.__Internals;
|
||||
using TerraFX.Interop.DirectX;
|
||||
|
||||
namespace ComputeSharp.Shaders.Dispatching;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using ComputeSharp.Descriptors;
|
||||
using TerraFX.Interop.DirectX;
|
||||
|
||||
namespace ComputeSharp.Shaders.Dispatching;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Descriptors;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
@@ -484,7 +485,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="x">The number of iterations to run on the X axis.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run.</param>
|
||||
public static void For<T>(this in ComputeContext context, int x, in T shader)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
context.Run(x, ref Unsafe.AsRef(in shader));
|
||||
}
|
||||
@@ -498,7 +499,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="y">The number of iterations to run on the Y axis.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run.</param>
|
||||
public static void For<T>(this in ComputeContext context, int x, int y, in T shader)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
context.Run(x, y, ref Unsafe.AsRef(in shader));
|
||||
}
|
||||
@@ -513,7 +514,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="z">The number of iterations to run on the Z axis.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run.</param>
|
||||
public static void For<T>(this in ComputeContext context, int x, int y, int z, in T shader)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
context.Run(x, y, z, ref Unsafe.AsRef(in shader));
|
||||
}
|
||||
@@ -526,7 +527,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to run the shader.</param>
|
||||
/// <param name="texture">The target texture to apply the pixel shader to.</param>
|
||||
public static void ForEach<T, TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture2D<TPixel> texture)
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where T : struct, IComputeShader<TPixel>, IComputeShaderDescriptor<T>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
@@ -543,7 +544,7 @@ public static class ComputeContextExtensions
|
||||
/// <param name="texture">The target texture to apply the pixel shader to.</param>
|
||||
/// <param name="shader">The input <typeparamref name="T"/> instance representing the pixel shader to run.</param>
|
||||
public static void ForEach<T, TPixel>(this in ComputeContext context, IReadWriteNormalizedTexture2D<TPixel> texture, in T shader)
|
||||
where T : struct, IPixelShader<TPixel>
|
||||
where T : struct, IComputeShader<TPixel>, IComputeShaderDescriptor<T>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
@@ -2,14 +2,12 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Shaders.Extensions;
|
||||
using ComputeSharp.Descriptors;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.__Internals;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_DESCRIPTOR_RANGE_FLAGS;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.Shaders.Loading;
|
||||
|
||||
/// <summary>
|
||||
@@ -17,7 +15,7 @@ namespace ComputeSharp.Shaders.Loading;
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of compute shader to load.</typeparam>
|
||||
internal static unsafe class PipelineDataLoader<T>
|
||||
where T : struct, IShader
|
||||
where T : struct, IComputeShaderDescriptor<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The map of cached <see cref="PipelineData"/> instances for each GPU in use.
|
||||
|
||||
@@ -177,7 +177,7 @@ public partial class DeviceDisposalTests
|
||||
}
|
||||
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
private partial struct HelloWorldShader : IPixelShader<float4>
|
||||
private partial struct HelloWorldShader : IComputeShader<float4>
|
||||
{
|
||||
public float4 Execute()
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ public partial class DispatchTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(8, 8, 1)]
|
||||
internal readonly partial struct PixelShader : IPixelShader<float4>
|
||||
internal readonly partial struct PixelShader : IComputeShader<float4>
|
||||
{
|
||||
private readonly float b;
|
||||
private readonly float a;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Descriptors;
|
||||
|
||||
namespace ComputeSharp.Tests.Internals.Helpers;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Descriptors;
|
||||
using ComputeSharp.Tests.Internals.Helpers;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
@@ -28,18 +28,18 @@ public partial class ShaderDataLoaderTests
|
||||
CapturedResourceShader shader = new(buffer);
|
||||
DebugDispatchDataLoader dataLoader = new();
|
||||
|
||||
((IShader)shader).LoadConstantBuffer(ref dataLoader, 111, 222, 333);
|
||||
((IComputeShaderDescriptor<CapturedResourceShader>)shader).LoadConstantBuffer(in shader, ref dataLoader, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(12, ((IShader)shader).ConstantBufferSize);
|
||||
Assert.AreEqual(12, ((IComputeShaderDescriptor<CapturedResourceShader>)shader).ConstantBufferSize);
|
||||
Assert.IsNotNull(dataLoader.ConstantBuffer);
|
||||
Assert.AreEqual(12, dataLoader.ConstantBuffer.Length);
|
||||
Assert.AreEqual(111, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[0]));
|
||||
Assert.AreEqual(222, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[4]));
|
||||
Assert.AreEqual(333, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[8]));
|
||||
|
||||
((IShader)shader).LoadGraphicsResources(ref dataLoader);
|
||||
((IComputeShaderDescriptor<CapturedResourceShader>)shader).LoadGraphicsResources(in shader, ref dataLoader);
|
||||
|
||||
Assert.AreEqual(1, ((IShader)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreEqual(1, ((IComputeShaderDescriptor<CapturedResourceShader>)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreSame(buffer, dataLoader.GraphicsResources[0].Resource);
|
||||
Assert.AreEqual(0u, dataLoader.GraphicsResources[0].Index);
|
||||
}
|
||||
@@ -68,9 +68,9 @@ public partial class ShaderDataLoaderTests
|
||||
MultipleResourcesAndPrimitivesShader shader = new(buffer0, buffer1, 1, 22, 77);
|
||||
DebugDispatchDataLoader dataLoader = new();
|
||||
|
||||
((IShader)shader).LoadConstantBuffer(ref dataLoader, 111, 222, 333);
|
||||
((IComputeShaderDescriptor<MultipleResourcesAndPrimitivesShader>)shader).LoadConstantBuffer(in shader, ref dataLoader, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(24, ((IShader)shader).ConstantBufferSize);
|
||||
Assert.AreEqual(24, ((IComputeShaderDescriptor<MultipleResourcesAndPrimitivesShader>)shader).ConstantBufferSize);
|
||||
Assert.IsNotNull(dataLoader.ConstantBuffer);
|
||||
Assert.AreEqual(24, dataLoader.ConstantBuffer.Length);
|
||||
Assert.AreEqual(111, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[0]));
|
||||
@@ -80,9 +80,9 @@ public partial class ShaderDataLoaderTests
|
||||
Assert.AreEqual(22, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[16]));
|
||||
Assert.AreEqual(77, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[20]));
|
||||
|
||||
((IShader)shader).LoadGraphicsResources(ref dataLoader);
|
||||
((IComputeShaderDescriptor<MultipleResourcesAndPrimitivesShader>)shader).LoadGraphicsResources(in shader, ref dataLoader);
|
||||
|
||||
Assert.AreEqual(2, ((IShader)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreEqual(2, ((IComputeShaderDescriptor<MultipleResourcesAndPrimitivesShader>)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreSame(buffer0, dataLoader.GraphicsResources[0].Resource);
|
||||
Assert.AreEqual(0u, dataLoader.GraphicsResources[0].Index);
|
||||
Assert.AreSame(buffer1, dataLoader.GraphicsResources[1].Resource);
|
||||
@@ -114,9 +114,9 @@ public partial class ShaderDataLoaderTests
|
||||
ScalarAndVectorTypesShader shader = new(buffer, new(55, 44, 888), 22, 77, new(3.14, 6.28), 42, 9999);
|
||||
DebugDispatchDataLoader dataLoader = new();
|
||||
|
||||
((IShader)shader).LoadConstantBuffer(ref dataLoader, 111, 222, 333);
|
||||
((IComputeShaderDescriptor<ScalarAndVectorTypesShader>)shader).LoadConstantBuffer(in shader, ref dataLoader, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(72, ((IShader)shader).ConstantBufferSize);
|
||||
Assert.AreEqual(72, ((IComputeShaderDescriptor<ScalarAndVectorTypesShader>)shader).ConstantBufferSize);
|
||||
Assert.IsNotNull(dataLoader.ConstantBuffer);
|
||||
Assert.AreEqual(72, dataLoader.ConstantBuffer.Length);
|
||||
Assert.AreEqual(111, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[0]));
|
||||
@@ -132,9 +132,9 @@ public partial class ShaderDataLoaderTests
|
||||
Assert.AreEqual(42, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[64]));
|
||||
Assert.AreEqual(9999, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[68]));
|
||||
|
||||
((IShader)shader).LoadGraphicsResources(ref dataLoader);
|
||||
((IComputeShaderDescriptor<ScalarAndVectorTypesShader>)shader).LoadGraphicsResources(in shader, ref dataLoader);
|
||||
|
||||
Assert.AreEqual(1, ((IShader)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreEqual(1, ((IComputeShaderDescriptor<ScalarAndVectorTypesShader>)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreSame(buffer, dataLoader.GraphicsResources[0].Resource);
|
||||
Assert.AreEqual(0u, dataLoader.GraphicsResources[0].Index);
|
||||
}
|
||||
@@ -175,9 +175,9 @@ public partial class ShaderDataLoaderTests
|
||||
d: 9999);
|
||||
DebugDispatchDataLoader dataLoader = new();
|
||||
|
||||
((IShader)shader).LoadConstantBuffer(ref dataLoader, 111, 222, 333);
|
||||
((IComputeShaderDescriptor<ScalarVectorAndMatrixTypesShader>)shader).LoadConstantBuffer(in shader, ref dataLoader, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(124, ((IShader)shader).ConstantBufferSize);
|
||||
Assert.AreEqual(124, ((IComputeShaderDescriptor<ScalarVectorAndMatrixTypesShader>)shader).ConstantBufferSize);
|
||||
Assert.IsNotNull(dataLoader.ConstantBuffer);
|
||||
Assert.AreEqual(124, dataLoader.ConstantBuffer.Length);
|
||||
Assert.AreEqual(111, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[0]));
|
||||
@@ -204,9 +204,9 @@ public partial class ShaderDataLoaderTests
|
||||
Assert.AreEqual(44, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[116]));
|
||||
Assert.AreEqual(9999, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[120]));
|
||||
|
||||
((IShader)shader).LoadGraphicsResources(ref dataLoader);
|
||||
((IComputeShaderDescriptor<ScalarVectorAndMatrixTypesShader>)shader).LoadGraphicsResources(in shader, ref dataLoader);
|
||||
|
||||
Assert.AreEqual(1, ((IShader)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreEqual(1, ((IComputeShaderDescriptor<ScalarVectorAndMatrixTypesShader>)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreSame(buffer, dataLoader.GraphicsResources[0].Resource);
|
||||
Assert.AreEqual(0u, dataLoader.GraphicsResources[0].Index);
|
||||
}
|
||||
@@ -254,9 +254,9 @@ public partial class ShaderDataLoaderTests
|
||||
d: 9999));
|
||||
DebugDispatchDataLoader dataLoader = new();
|
||||
|
||||
((IShader)shader).LoadConstantBuffer(ref dataLoader, 111, 222, 333);
|
||||
((IComputeShaderDescriptor<FlatCustomTypeShader>)shader).LoadConstantBuffer(in shader, ref dataLoader, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(124, ((IShader)shader).ConstantBufferSize);
|
||||
Assert.AreEqual(124, ((IComputeShaderDescriptor<FlatCustomTypeShader>)shader).ConstantBufferSize);
|
||||
Assert.IsNotNull(dataLoader.ConstantBuffer);
|
||||
Assert.AreEqual(124, dataLoader.ConstantBuffer.Length);
|
||||
Assert.AreEqual(111, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[0]));
|
||||
@@ -283,9 +283,9 @@ public partial class ShaderDataLoaderTests
|
||||
Assert.AreEqual(44, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[116]));
|
||||
Assert.AreEqual(9999, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[120]));
|
||||
|
||||
((IShader)shader).LoadGraphicsResources(ref dataLoader);
|
||||
((IComputeShaderDescriptor<FlatCustomTypeShader>)shader).LoadGraphicsResources(in shader, ref dataLoader);
|
||||
|
||||
Assert.AreEqual(1, ((IShader)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreEqual(1, ((IComputeShaderDescriptor<FlatCustomTypeShader>)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreSame(buffer, dataLoader.GraphicsResources[0].Resource);
|
||||
Assert.AreEqual(0u, dataLoader.GraphicsResources[0].Index);
|
||||
}
|
||||
@@ -357,9 +357,9 @@ public partial class ShaderDataLoaderTests
|
||||
b: new(333.3f, 444.4f))));
|
||||
DebugDispatchDataLoader dataLoader = new();
|
||||
|
||||
((IShader)shader).LoadConstantBuffer(ref dataLoader, 111, 222, 333);
|
||||
((IComputeShaderDescriptor<NestedCustomTypesShader>)shader).LoadConstantBuffer(in shader, ref dataLoader, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(188, ((IShader)shader).ConstantBufferSize);
|
||||
Assert.AreEqual(188, ((IComputeShaderDescriptor<NestedCustomTypesShader>)shader).ConstantBufferSize);
|
||||
Assert.IsNotNull(dataLoader.ConstantBuffer);
|
||||
Assert.AreEqual(188, dataLoader.ConstantBuffer.Length);
|
||||
Assert.AreEqual(111, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[0]));
|
||||
@@ -399,9 +399,9 @@ public partial class ShaderDataLoaderTests
|
||||
Assert.AreEqual(333.3f, Unsafe.As<byte, float>(ref dataLoader.ConstantBuffer[180]));
|
||||
Assert.AreEqual(444.4f, Unsafe.As<byte, float>(ref dataLoader.ConstantBuffer[184]));
|
||||
|
||||
((IShader)shader).LoadGraphicsResources(ref dataLoader);
|
||||
((IComputeShaderDescriptor<NestedCustomTypesShader>)shader).LoadGraphicsResources(in shader, ref dataLoader);
|
||||
|
||||
Assert.AreEqual(1, ((IShader)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreEqual(1, ((IComputeShaderDescriptor<NestedCustomTypesShader>)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreSame(buffer, dataLoader.GraphicsResources[0].Resource);
|
||||
Assert.AreEqual(0u, dataLoader.GraphicsResources[0].Index);
|
||||
}
|
||||
@@ -438,9 +438,9 @@ public partial class ShaderDataLoaderTests
|
||||
AmbiguousNamesShader shader = new(a, b, c, x, y, z, 7777, 8888, 9999);
|
||||
DebugDispatchDataLoader dataLoader = new();
|
||||
|
||||
((IShader)shader).LoadConstantBuffer(ref dataLoader, 111, 222, 333);
|
||||
((IComputeShaderDescriptor<AmbiguousNamesShader>)shader).LoadConstantBuffer(in shader, ref dataLoader, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(24, ((IShader)shader).ConstantBufferSize);
|
||||
Assert.AreEqual(24, ((IComputeShaderDescriptor<AmbiguousNamesShader>)shader).ConstantBufferSize);
|
||||
Assert.IsNotNull(dataLoader.ConstantBuffer);
|
||||
Assert.AreEqual(24, dataLoader.ConstantBuffer.Length);
|
||||
Assert.AreEqual(111, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[0]));
|
||||
@@ -450,9 +450,9 @@ public partial class ShaderDataLoaderTests
|
||||
Assert.AreEqual(8888, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[16]));
|
||||
Assert.AreEqual(9999, Unsafe.As<byte, int>(ref dataLoader.ConstantBuffer[20]));
|
||||
|
||||
((IShader)shader).LoadGraphicsResources(ref dataLoader);
|
||||
((IComputeShaderDescriptor<AmbiguousNamesShader>)shader).LoadGraphicsResources(in shader, ref dataLoader);
|
||||
|
||||
Assert.AreEqual(6, ((IShader)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreEqual(6, ((IComputeShaderDescriptor<AmbiguousNamesShader>)shader).ResourceDescriptorRanges.Length);
|
||||
Assert.AreSame(a, dataLoader.GraphicsResources[0].Resource);
|
||||
Assert.AreEqual(0u, dataLoader.GraphicsResources[0].Index);
|
||||
Assert.AreSame(b, dataLoader.GraphicsResources[1].Resource);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0001", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0001", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -62,7 +62,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0001", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0001", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -91,7 +91,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0002", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0002", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -120,7 +120,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0003", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0003", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -147,7 +147,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0004", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0004", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -165,7 +165,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0005", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0005", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -201,7 +201,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, diagnosticsId, "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, diagnosticsId, "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -234,7 +234,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, diagnosticsId, "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, diagnosticsId, "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -265,7 +265,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0006", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0006", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -293,7 +293,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0010", "CMPS0031", "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0010", "CMPS0031", "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -321,7 +321,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0010", "CMPS0031", "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0010", "CMPS0031", "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -349,7 +349,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0011", "CMPS0031", "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0011", "CMPS0031", "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -379,7 +379,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0012", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0012", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -406,7 +406,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0012", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0012", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -434,7 +434,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0012", "CMPS0013", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0012", "CMPS0013", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -464,7 +464,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0014", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0014", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -497,7 +497,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0015", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0015", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -530,7 +530,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0016", "CMPS0032", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0016", "CMPS0032", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -563,7 +563,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0017", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0017", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -593,7 +593,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0018", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0018", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -624,7 +624,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0019", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0019", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -655,7 +655,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0020", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0020", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -688,7 +688,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0021", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0021", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -719,7 +719,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0022", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0022", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -752,7 +752,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0023", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0023", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -780,7 +780,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0024", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0024", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -808,7 +808,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0032", "CMPS0025", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0032", "CMPS0025", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -836,7 +836,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0026", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0026", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -869,7 +869,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0027", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0027", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -897,7 +897,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0028", "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0028", "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -925,7 +925,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0029", "CMPS0031", "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0029", "CMPS0031", "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -955,7 +955,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0029", "CMPS0031", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0029", "CMPS0031", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -989,7 +989,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0030", "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0030", "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1017,7 +1017,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0031", "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0031", "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1045,7 +1045,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0032", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0032", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1073,7 +1073,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0033", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0033", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1103,7 +1103,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0034", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0034", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1133,7 +1133,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0035", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0035", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1163,7 +1163,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0035", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0035", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1191,7 +1191,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0036", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0036", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1235,7 +1235,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0037", "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0037", "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1264,7 +1264,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0038", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0038", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1293,7 +1293,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0040", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1327,7 +1327,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0040", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1359,7 +1359,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0040", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1388,7 +1388,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0040", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1417,7 +1417,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0040", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1452,7 +1452,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0041", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0041", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1464,12 +1464,12 @@ public class DiagnosticsTests
|
||||
namespace ComputeSharp
|
||||
{
|
||||
public interface IComputeShader { }
|
||||
public interface IPixelShader<TPixel> { }
|
||||
public interface IComputeShader<TPixel> { }
|
||||
}
|
||||
|
||||
namespace MyFancyApp.Sample
|
||||
{
|
||||
public struct MyShader : IComputeShader, IPixelShader<float4>
|
||||
public struct MyShader : IComputeShader, IComputeShader<float4>
|
||||
{
|
||||
public void Execute()
|
||||
{
|
||||
@@ -1478,7 +1478,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0042", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0042", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1518,7 +1518,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0044");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0044");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1553,7 +1553,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0048");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0048");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1588,7 +1588,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0048");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0048");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1623,7 +1623,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0048");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0048");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1652,7 +1652,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0049", "CMPS0047");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0049", "CMPS0047");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1681,7 +1681,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1716,7 +1716,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1749,7 +1749,7 @@ public class DiagnosticsTests
|
||||
}
|
||||
""";
|
||||
|
||||
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0047", "CMPS0050");
|
||||
VerifyGeneratedDiagnostics<ComputeShaderDescriptorGenerator>(source, "CMPS0047", "CMPS0050");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1309,7 +1309,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct ClearPixelShader : IPixelShader<float4>
|
||||
internal readonly partial struct ClearPixelShader : IComputeShader<float4>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public float4 Execute()
|
||||
@@ -1320,7 +1320,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct ColorPixelShader : IPixelShader<float4>
|
||||
internal readonly partial struct ColorPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly float4 color;
|
||||
|
||||
@@ -1333,7 +1333,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct LinearSampling2DPixelShader : IPixelShader<float4>
|
||||
internal readonly partial struct LinearSampling2DPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly IReadOnlyTexture2D<float4> source;
|
||||
|
||||
@@ -1365,7 +1365,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct LinearSamplingFromNormalized2DPixelShader : IPixelShader<float4>
|
||||
internal readonly partial struct LinearSamplingFromNormalized2DPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture2D<float4> source;
|
||||
|
||||
@@ -1378,7 +1378,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct CopyToOutputPixelShader : IPixelShader<float4>
|
||||
internal readonly partial struct CopyToOutputPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture2D<float4> source;
|
||||
|
||||
@@ -1391,7 +1391,7 @@ public partial class ComputeContextTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct InvertPixelShader : IPixelShader<float4>
|
||||
internal readonly partial struct InvertPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly IReadWriteNormalizedTexture2D<float4> source;
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ public partial class DispatchTests
|
||||
}
|
||||
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct DispatchPixelShader : IPixelShader<float4>
|
||||
internal readonly partial struct DispatchPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public float4 Execute()
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ public partial class IPixelShaderTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct EarlyReturnShader : IPixelShader<float4>
|
||||
internal readonly partial struct EarlyReturnShader : IComputeShader<float4>
|
||||
{
|
||||
public float4 Execute()
|
||||
{
|
||||
|
||||
@@ -294,7 +294,7 @@ namespace ComputeSharp.Tests
|
||||
}
|
||||
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
public readonly partial struct StatelessPixelShader : IPixelShader<float4>
|
||||
public readonly partial struct StatelessPixelShader : IComputeShader<float4>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public float4 Execute()
|
||||
@@ -406,7 +406,7 @@ namespace ComputeSharp.Tests
|
||||
_ = ReflectionServices.GetShaderInfo<PixelShaderWithInheritedShaderInterfaceShader, float4>();
|
||||
}
|
||||
|
||||
public interface IMyBaseShader<T> : IPixelShader<T>
|
||||
public interface IMyBaseShader<T> : IComputeShader<T>
|
||||
where T : unmanaged
|
||||
{
|
||||
public int A { get; }
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ComputeSharp.SwapChain.Shaders.Compute;
|
||||
/// </summary>
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
internal readonly partial struct HelloWorld : IPixelShader<float4>
|
||||
internal readonly partial struct HelloWorld : IComputeShader<float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current time since the start of the application.
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Descriptors;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.SwapChain.Shaders;
|
||||
using ComputeSharp.Tests.Attributes;
|
||||
@@ -169,7 +170,7 @@ public class ShadersTests
|
||||
if (typeof(IComputeShader).IsAssignableFrom(shaderType))
|
||||
{
|
||||
static void RunComputeShader<T>(ReadWriteTexture2D<Rgba32, float4> texture)
|
||||
where T : struct, IComputeShader
|
||||
where T : struct, IComputeShader, IComputeShaderDescriptor<T>
|
||||
{
|
||||
ShaderInfo info = ReflectionServices.GetShaderInfo<T>();
|
||||
|
||||
@@ -185,7 +186,7 @@ public class ShadersTests
|
||||
else
|
||||
{
|
||||
static void RunPixelShader<T>(ReadWriteTexture2D<Rgba32, float4> texture)
|
||||
where T : struct, IPixelShader<float4>
|
||||
where T : struct, IComputeShader<float4>, IComputeShaderDescriptor<T>
|
||||
{
|
||||
ShaderInfo info = ReflectionServices.GetShaderInfo<T, float4>();
|
||||
|
||||
@@ -229,8 +230,8 @@ public class ShadersTests
|
||||
Func<ReadWriteTexture2D<Rgba32, float4>, TCompute> computeFactory,
|
||||
Func<ReadWriteTexture2D<Rgba32, float4>, TPixel> pixelFactory,
|
||||
float delta)
|
||||
where TCompute : struct, IComputeShader
|
||||
where TPixel : struct, IPixelShader<float4>
|
||||
where TCompute : struct, IComputeShader, IComputeShaderDescriptor<TCompute>
|
||||
where TPixel : struct, IComputeShader<float4>, IComputeShaderDescriptor<TPixel>
|
||||
{
|
||||
_ = device.Get();
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ partial class Texture2DTests
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.XY)]
|
||||
public readonly partial struct SamplingPixelShader : IPixelShader<float4>
|
||||
public readonly partial struct SamplingPixelShader : IComputeShader<float4>
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture2D<float4> texture;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Descriptors;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace ComputeSharp.Tests;
|
||||
@@ -10,21 +10,21 @@ public partial class ThreadGroupSizeTests
|
||||
[TestMethod]
|
||||
public unsafe void Verify_ThreadGroupSize()
|
||||
{
|
||||
Assert.AreEqual(64, ((IShader)default(DispatchXShader)).ThreadsX);
|
||||
Assert.AreEqual(1, ((IShader)default(DispatchXShader)).ThreadsY);
|
||||
Assert.AreEqual(1, ((IShader)default(DispatchXShader)).ThreadsZ);
|
||||
Assert.AreEqual(64, ((IComputeShaderDescriptor<DispatchXShader>)default(DispatchXShader)).ThreadsX);
|
||||
Assert.AreEqual(1, ((IComputeShaderDescriptor<DispatchXShader>)default(DispatchXShader)).ThreadsY);
|
||||
Assert.AreEqual(1, ((IComputeShaderDescriptor<DispatchXShader>)default(DispatchXShader)).ThreadsZ);
|
||||
|
||||
Assert.AreEqual(8, ((IShader)default(DispatchXYShader)).ThreadsX);
|
||||
Assert.AreEqual(8, ((IShader)default(DispatchXYShader)).ThreadsY);
|
||||
Assert.AreEqual(1, ((IShader)default(DispatchXYShader)).ThreadsZ);
|
||||
Assert.AreEqual(8, ((IComputeShaderDescriptor<DispatchXYShader>)default(DispatchXYShader)).ThreadsX);
|
||||
Assert.AreEqual(8, ((IComputeShaderDescriptor<DispatchXYShader>)default(DispatchXYShader)).ThreadsY);
|
||||
Assert.AreEqual(1, ((IComputeShaderDescriptor<DispatchXYShader>)default(DispatchXYShader)).ThreadsZ);
|
||||
|
||||
Assert.AreEqual(4, ((IShader)default(DispatchXYZShader)).ThreadsX);
|
||||
Assert.AreEqual(4, ((IShader)default(DispatchXYZShader)).ThreadsY);
|
||||
Assert.AreEqual(4, ((IShader)default(DispatchXYZShader)).ThreadsZ);
|
||||
Assert.AreEqual(4, ((IComputeShaderDescriptor<DispatchXYZShader>)default(DispatchXYZShader)).ThreadsX);
|
||||
Assert.AreEqual(4, ((IComputeShaderDescriptor<DispatchXYZShader>)default(DispatchXYZShader)).ThreadsY);
|
||||
Assert.AreEqual(4, ((IComputeShaderDescriptor<DispatchXYZShader>)default(DispatchXYZShader)).ThreadsZ);
|
||||
|
||||
Assert.AreEqual(11, ((IShader)default(DispatchCustomShader)).ThreadsX);
|
||||
Assert.AreEqual(14, ((IShader)default(DispatchCustomShader)).ThreadsY);
|
||||
Assert.AreEqual(6, ((IShader)default(DispatchCustomShader)).ThreadsZ);
|
||||
Assert.AreEqual(11, ((IComputeShaderDescriptor<DispatchCustomShader>)default(DispatchCustomShader)).ThreadsX);
|
||||
Assert.AreEqual(14, ((IComputeShaderDescriptor<DispatchCustomShader>)default(DispatchCustomShader)).ThreadsY);
|
||||
Assert.AreEqual(6, ((IComputeShaderDescriptor<DispatchCustomShader>)default(DispatchCustomShader)).ThreadsZ);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする