Add [EmbeddedBytecode] attribute

このコミットが含まれているのは:
Sergio Pedri committed 2021-12-06 17:43:43 +01:00
1 親 cd7d4c8362
コミット 92b2934229
3ファイル変更
+60 -5

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

+1
ファイルの表示
@@ -18,6 +18,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Path.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InterpolatedStringHandlerArgumentAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InterpolatedStringHandlerAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IsExternalInit.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\SkipLocalsInitAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\MemoryMarshal.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\RuntimeHelpers.cs" />
@@ -1,8 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using System.ComponentModel;
namespace System.Runtime.CompilerServices;
+58
ファイルの表示
@@ -0,0 +1,58 @@
using System;
namespace ComputeSharp;
/// <summary>
/// An attribute that indicates that a given shader should be precompiled at build time and embedded
/// directly into the containing assembly as static bytecode, to avoid compiling it at runtime.
/// <para>
/// This attribute can be used to annotate shader types as follows:
/// <code>
/// [EmbeddedBytecode(8, 8, 1)]
/// struct MyShader : IComputeShader
/// {
/// }
/// </code>
/// </para>
/// <para>
/// This attribute can only be used when the shader type being annotated does not require dynamic
/// features. Specifically, this attribute is not supported if the shader captures any delegates.
/// </para>
/// The runtime compilation will automatically be skipped if the shader is invoked using matching
/// thread count values, otherwise the usual runtime compilation will be used as fallback. In case
/// the fallback support is not needed and all shaders in use are being precompiled, it is possible
/// to skip bundling the native <c>dxcompiler.dll</c> and <c>dxil.dll</c> libraries included with
/// ComputeSharp entirely, resulting in a smaller binary size in consuming applications. To do this,
/// the <c>PackageReference</c> item for the library should be annotated with <c>ExcludeAssets="native"</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class EmbeddedBytecodeAttribute : Attribute
{
/// <summary>
/// Creates a new <see cref="EmbeddedBytecodeAttribute"/> instance with the specified parameters.
/// </summary>
/// <param name="threadsX">The number of threads in each thread group for the X axis.</param>
/// <param name="threadsY">The number of threads in each thread group for the Y axis.</param>
/// <param name="threadsZ">The number of threads in each thread group for the Z axis.</param>
public EmbeddedBytecodeAttribute(int threadsX, int threadsY, int threadsZ)
{
ThreadsX = threadsX;
ThreadsY = threadsY;
ThreadsZ = threadsZ;
}
/// <summary>
/// Gets the number of threads in each thread group for the X axis
/// </summary>
public int ThreadsX { get; init; }
/// <summary>
/// Gets the number of threads in each thread group for the Y axis
/// </summary>
public int ThreadsY { get; init; }
/// <summary>
/// Gets the number of threads in each thread group for the Z axis
/// </summary>
public int ThreadsZ { get; init; }
}