Consolidated library projects into a single one

This is necessary to produce a single output assembly
このコミットが含まれているのは:
Sergio Pedri committed 2021-02-25 18:56:27 +01:00
1 親 a5217eef08
コミット db2cb188ec
163ファイル変更
+228 -312

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

-12
ファイルの表示
@@ -1,12 +0,0 @@
using System;
namespace ComputeSharp
{
/// <summary>
/// An attribute that indicates that a target shader type should get an automatic constructor for all fields.
/// </summary>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class AutoConstructorAttribute : Attribute
{
}
}
-46
ファイルの表示
@@ -1,46 +0,0 @@
using System;
namespace ComputeSharp
{
/// <summary>
/// An attribute that indicates that an array static field in a shader type will be shared in a thread group.
/// <para>
/// This attribute can be used to declare fields as follows:
/// <code>
/// struct MyShader : IComputeShader
/// {
/// [GroupShared(32)]
/// static float[] MyBuffer;
/// }
/// </code>
/// </para>
/// The buffer shouldn't be manually initialized, as each shader invocation will automatically receive the
/// right buffer in use for the thread group it belongs to. If there is an assignment for the field, it
/// will just be ignored in the shader. Additionally, buffer types are not allowed as array items.
/// </summary>
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public sealed class GroupSharedAttribute : Attribute
{
/// <summary>
/// Creates a new <see cref="GroupSharedAttribute"/> instance with the specified parameters.
/// </summary>
public GroupSharedAttribute()
{
}
/// <summary>
/// Creates a new <see cref="GroupSharedAttribute"/> instance with the specified parameters.
/// </summary>
/// <param name="size">The size of the shared buffer to declare.</param>
public GroupSharedAttribute(int size)
{
Size = size;
}
/// <summary>
/// Gets the size of the shared buffer being declared.
/// If <see langword="null"/>, the thread group size will be used.
/// </summary>
public int? Size { get; }
}
}
-16
ファイルの表示
@@ -1,16 +0,0 @@
using System;
namespace ComputeSharp
{
/// <summary>
/// An attribute that indicates that a method will be indirectly used in a compute shader.
/// This method is necessary for methods that are captured and used within a given shader
/// through a <see cref="Delegate"/> field (of some custom type). In order to be processed
/// correctly, wrapped methods need to have this attribute manually applied to them.
/// Methods also need to be static, though this can only be tested at runtime.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class ShaderMethodAttribute : Attribute
{
}
}
-29
ファイルの表示
@@ -1,29 +0,0 @@
using System;
using System.ComponentModel;
namespace ComputeSharp.__Internals
{
/// <summary>
/// An attribute that contains info on the number of 32 bit constants for a given shader.
/// </summary>
/// <remarks>This attribute is not meant to be directly used by applications using ComputeSharp.</remarks>
[AttributeUsage(AttributeTargets.ReturnValue, AllowMultiple = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This attribute is not intended to be used directly by user code")]
public sealed class ComputeRoot32BitConstantsAttribute : Attribute
{
/// <summary>
/// Creates a new <see cref="ComputeRoot32BitConstantsAttribute"/> instance with the specified parameters.
/// </summary>
/// <param name="count">The number of 32 bit constants for the annotated method.</param>
public ComputeRoot32BitConstantsAttribute(int count)
{
Count = count;
}
/// <summary>
/// Gets the number of 32 bit constants for the annotated method.
/// </summary>
internal int Count { get; }
}
}
-95
ファイルの表示
@@ -1,95 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reflection;
namespace ComputeSharp.__Internals
{
/// <summary>
/// An attribute that contains info on a processed compute shader that can be executed.
/// </summary>
/// <remarks>This attribute is not meant to be directly used by applications using ComputeSharp.</remarks>
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This attribute is not intended to be used directly by user code")]
public sealed class IComputeShaderSourceAttribute : Attribute
{
/// <summary>
/// Creates a new <see cref="IComputeShaderSourceAttribute"/> instance with the specified parameters.
/// </summary>
/// <param name="shaderType">The type of the current shader.</param>
/// <param name="types">The collection of custom types.</param>
/// <param name="args">The mapped collection of shader fields.</param>
/// <param name="executeMethod">The source code for the <see cref="IComputeShader.Execute"/> method.</param>
/// <param name="methods">The collection of processed methods.</param>
/// <param name="constants">The collection of discovered constants.</param>
/// <param name="sharedBuffers">The collection of group shared buffers.</param>
public IComputeShaderSourceAttribute(
Type shaderType,
string[] types,
object[] args,
string executeMethod,
string[] methods,
object[] constants,
object[] sharedBuffers)
{
ShaderType = shaderType;
Types = types;
Fields = args.Cast<string[]>().ToDictionary(static arg => arg[0], static arg => (arg[1], arg[2]));
ExecuteMethod = executeMethod;
Methods = methods;
Constants = constants.Cast<string[]>().ToDictionary(static c => c[0], static c => c[1]);
SharedBuffers = sharedBuffers.Cast<object[]>().ToDictionary(static t => (string)t[0], static t => ((string)t[1], (int?)t[2]));
}
/// <summary>
/// Gets the type of the current shader.
/// </summary>
internal Type ShaderType { get; }
/// <summary>
/// Gets the collection of processed custom types.
/// </summary>
internal IReadOnlyCollection<string> Types { get; }
/// <summary>
/// Gets the mapping of field names.
/// </summary>
internal IReadOnlyDictionary<string, (string Name, string Type)> Fields { get; }
/// <summary>
/// Gets the source code for the <see cref="IComputeShader.Execute"/> method.
/// </summary>
internal string ExecuteMethod { get; }
/// <summary>
/// Gets the collection of processed methods.
/// </summary>
internal IReadOnlyCollection<string> Methods { get; }
/// <summary>
/// Gets the collection of discovered constants.
/// </summary>
internal IReadOnlyDictionary<string, string> Constants { get; }
/// <summary>
/// Gets the collection of discovered constants.
/// </summary>
internal IReadOnlyDictionary<string, (string Type, int? Count)> SharedBuffers { get; }
/// <summary>
/// Gets the associated <see cref="IComputeShaderSourceAttribute"/> instance for a specified type.
/// </summary>
/// <typeparam name="T">The shader type to get the attribute for.</typeparam>
/// <returns>The associated <see cref="IComputeShaderSourceAttribute"/> instance for type <typeparamref name="T"/>.</returns>
[Pure]
internal static IComputeShaderSourceAttribute GetForType<T>()
{
Type shaderType = typeof(T);
return shaderType.Assembly.GetCustomAttributes<IComputeShaderSourceAttribute>().Single(attribute => attribute.ShaderType == shaderType);
}
}
}
-116
ファイルの表示
@@ -1,116 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reflection;
using ComputeSharp.Core.Extensions;
using ComputeSharp.Exceptions;
namespace ComputeSharp.__Internals
{
/// <summary>
/// An attribute that contains info on a processed shader method that can be executed within a shader.
/// Instances of this attribute are generated from method annotated with <see cref="ShaderMethodAttribute"/>.
/// </summary>
/// <remarks>This attribute is not meant to be directly used by applications using ComputeSharp.</remarks>
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This attribute is not intended to be used directly by user code")]
public sealed class ShaderMethodSourceAttribute : Attribute
{
/// <summary>
/// The identifier for the invoke method, for late binding.
/// </summary>
internal const string InvokeMethodIdentifier = "__<NAME>__";
/// <summary>
/// The source code for the target entry point method.
/// </summary>
private readonly string invokeMethod;
/// <summary>
/// Creates a new <see cref="ShaderMethodSourceAttribute"/> instance with the specified parameters.
/// </summary>
/// <param name="methodName">The fully qualified name of the current method.</param>
/// <param name="types">The collection of custom types.</param>
/// <param name="invokeMethod">The source code for the target entry point method.</param>
/// <param name="methods">The collection of processed methods.</param>
/// <param name="constants">The collection of discovered constants.</param>
public ShaderMethodSourceAttribute(string methodName, string[] types, string invokeMethod, string[] methods, object[] constants)
{
this.invokeMethod = invokeMethod;
MethodName = methodName;
Types = types;
Methods = methods;
Constants = constants.Cast<string[]>().ToDictionary(static c => c[0], static c => c[1]);
}
/// <summary>
/// Gets the fully qualified name of the shader type.
/// </summary>
internal string MethodName { get; }
/// <summary>
/// Gets the collection of processed custom types.
/// </summary>
internal IReadOnlyCollection<string> Types { get; }
/// <summary>
/// Gets the collection of processed methods.
/// </summary>
internal IReadOnlyCollection<string> Methods { get; }
/// <summary>
/// Gets the collection of discovered constants.
/// </summary>
internal IReadOnlyDictionary<string, string> Constants { get; }
/// <summary>
/// Gets the mapped source code for the current method.
/// </summary>
/// <param name="name">The name to bind the method to.</param>
/// <returns>The mapped source code for the current mehtod.</returns>
[Pure]
internal string GetMappedInvokeMethod(string name)
{
return this.invokeMethod.Replace(InvokeMethodIdentifier, name);
}
/// <summary>
/// Gets the associated <see cref="ShaderMethodSourceAttribute"/> instance for a specified delegate.
/// </summary>
/// <param name="function">The input <see cref="Delegate"/> instance to get info for.</param>
/// <returns>The associated <see cref="ShaderMethodSourceAttribute"/> instance for the given delegate.</returns>
[Pure]
internal static ShaderMethodSourceAttribute GetForDelegate(Delegate function)
{
if (!function.Method.IsStatic)
{
ThrowArgumentExceptionForNonStaticShader();
}
var attributes = function.Method.DeclaringType!.Assembly.GetCustomAttributes<ShaderMethodSourceAttribute>();
string methodName = function.Method.GetFullName();
foreach (var attribute in attributes)
{
if (attribute.MethodName.Equals(methodName))
{
return attribute;
}
}
return MissingMethodSourceException.Throw(function);
}
/// <summary>
/// Throws an <see cref="ArgumentException"/> when a given <see cref="Delegate"/> is not static.
/// </summary>
private static void ThrowArgumentExceptionForNonStaticShader()
{
throw new ArgumentException("Captured delegates in a shader need to wrap a static method.", "function");
}
}
}