Rename IPixelShader<TPixel> to IComputeShader<TPixel>

このコミットが含まれているのは:
Sergio Pedri committed 2023-10-15 21:10:59 +02:00
1 親 c31c63cf82
コミット de498f338a
36ファイル変更
+69 -65

検索条件に一致するファイルはありません

+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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.
+1 -1
ファイルの表示
@@ -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 -1
ファイルの表示
@@ -11,7 +11,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>
{
/// <summary>
/// The <see cref="Func{T1, TResult}"/> instance used to create shaders to run.
+2 -2
ファイルの表示
@@ -70,7 +70,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>
where TPixel : unmanaged
{
return GetNonGenericShaderInfo(default(T));
@@ -89,7 +89,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>
where TPixel : unmanaged
{
return GetNonGenericShaderInfo(in shader);
+1 -1
ファイルの表示
@@ -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" />
+3 -3
ファイルの表示
@@ -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);
+1 -1
ファイルの表示
@@ -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)
{
+1 -1
ファイルの表示
@@ -12,7 +12,7 @@ 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 data loaders for <see cref="IComputeShader"/> and <see cref="IComputeShader{TPixel}"/> types.
/// </summary>
[Generator(LanguageNames.CSharp)]
public sealed partial class IShaderGenerator : IIncrementalGenerator
+1 -1
ファイルの表示
@@ -8,7 +8,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>
{
/// <summary>
/// The <see cref="Func{T1,TResult}"/> instance used to create shaders to run.
+1 -1
ファイルの表示
@@ -18,7 +18,7 @@ namespace ComputeSharp;
/// <code>
/// // A pixel shader that is dispatched on a target texture
/// [EmbeddedBytecode(DispatchAxis.XY)]
/// struct MyShader : IPixelShader&lt;float4&gt;
/// struct MyShader : IComputeShader&lt;float4&gt;
/// {
/// }
/// </code>
+22
ファイルの表示
@@ -0,0 +1,22 @@
using ComputeSharp.__Internals;
#pragma warning disable CS0618
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> : IShader
where TPixel : unmanaged
{
/// <summary>
/// Executes the current compute shader.
/// </summary>
/// <returns>The pixel value for the current invocation.</returns>
TPixel Execute();
}
-18
ファイルの表示
@@ -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();
}
+2 -2
ファイルの表示
@@ -71,7 +71,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>
where TPixel : unmanaged
{
default(ArgumentNullException).ThrowIfNull(device);
@@ -91,7 +91,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>
where TPixel : unmanaged
{
default(ArgumentNullException).ThrowIfNull(device);
+1 -1
ファイルの表示
@@ -191,7 +191,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>
where TPixel : unmanaged
{
default(InvalidOperationException).ThrowIf(this.device is null);
+2 -2
ファイルの表示
@@ -526,7 +526,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>
where TPixel : unmanaged
{
default(ArgumentNullException).ThrowIfNull(texture);
@@ -543,7 +543,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>
where TPixel : unmanaged
{
default(ArgumentNullException).ThrowIfNull(texture);
+1 -1
ファイルの表示
@@ -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()
{
+1 -1
ファイルの表示
@@ -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;
+2 -2
ファイルの表示
@@ -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()
{
+6 -6
ファイルの表示
@@ -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;
+1 -1
ファイルの表示
@@ -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()
{
+1 -1
ファイルの表示
@@ -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()
{
+2 -2
ファイルの表示
@@ -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; }
+1 -1
ファイルの表示
@@ -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 -2
ファイルの表示
@@ -185,7 +185,7 @@ public class ShadersTests
else
{
static void RunPixelShader<T>(ReadWriteTexture2D<Rgba32, float4> texture)
where T : struct, IPixelShader<float4>
where T : struct, IComputeShader<float4>
{
ShaderInfo info = ReflectionServices.GetShaderInfo<T, float4>();
@@ -230,7 +230,7 @@ public class ShadersTests
Func<ReadWriteTexture2D<Rgba32, float4>, TPixel> pixelFactory,
float delta)
where TCompute : struct, IComputeShader
where TPixel : struct, IPixelShader<float4>
where TPixel : struct, IComputeShader<float4>
{
_ = device.Get();
+1 -1
ファイルの表示
@@ -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;