Rename IPixelShader<TPixel> to IComputeShader<TPixel>
このコミットが含まれているのは:
1 親
c31c63cf82
コミット
de498f338a
36ファイル変更
+69
-65
検索条件に一致するファイルはありません
@@ -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);
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする