Enable linking support discovery and generation
このコミットが含まれているのは:
1 親
601cd3478e
コミット
8d3a7a0771
7ファイル変更
+78
-51
検索条件に一致するファイルはありません
+37
-9
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using ComputeSharp.D2D1Interop.Exceptions;
|
||||
@@ -36,24 +37,48 @@ partial class ID2D1ShaderGenerator
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extracts the metadata definition for the current shader.
|
||||
/// </summary>
|
||||
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
|
||||
/// <returns>Whether the shader only has simple inputs.</returns>
|
||||
public static bool IsSimpleInputShader(INamedTypeSymbol structDeclarationSymbol)
|
||||
{
|
||||
if (!structDeclarationSymbol.TryGetAttributeWithFullyQualifiedName("ComputeSharp.D2D1Interop.D2DInputCountAttribute", out AttributeData? inputCountAttribute))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Build a map of all simple inputs (unmarked inputs default to being complex)
|
||||
int inputCount = (int)inputCountAttribute!.ConstructorArguments[0].Value!;
|
||||
bool[] simpleInputsMap = new bool[inputCount];
|
||||
|
||||
foreach (AttributeData attributeData in structDeclarationSymbol.GetAttributes())
|
||||
{
|
||||
switch (attributeData.AttributeClass?.GetFullMetadataName())
|
||||
{
|
||||
case "ComputeSharp.D2D1Interop.D2DInputSimpleAttribute":
|
||||
simpleInputsMap[(int)attributeData.ConstructorArguments[0].Value!] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return simpleInputsMap.All(static x => x);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="BlockSyntax"/> instance with the logic to try to get a compiled shader bytecode.
|
||||
/// </summary>
|
||||
/// <param name="hlslSource">The generated HLSL source code (ignoring captured delegates, if present).</param>
|
||||
/// <param name="shaderProfile">The shader profile to use to compile the shader, if requested.</param>
|
||||
/// <param name="sourceInfo">The source info for the shader to compile.</param>
|
||||
/// <param name="token">The <see cref="CancellationToken"/> used to cancel the operation, if needed.</param>
|
||||
/// <param name="diagnostic">The resulting diagnostic from the processing operation, if any.</param>
|
||||
/// <returns>The <see cref="ImmutableArray{T}"/> instance with the compiled shader bytecode.</returns>
|
||||
public static unsafe ImmutableArray<byte> GetBytecode(
|
||||
string hlslSource,
|
||||
D2D1ShaderProfile? shaderProfile,
|
||||
CancellationToken token,
|
||||
out DiagnosticInfo? diagnostic)
|
||||
public static unsafe ImmutableArray<byte> GetBytecode(HlslShaderSourceInfo sourceInfo, CancellationToken token, out DiagnosticInfo? diagnostic)
|
||||
{
|
||||
ImmutableArray<byte> bytecode = ImmutableArray<byte>.Empty;
|
||||
|
||||
// No embedded shader was requested
|
||||
if (shaderProfile is null)
|
||||
if (sourceInfo.ShaderProfile is null)
|
||||
{
|
||||
diagnostic = null;
|
||||
|
||||
@@ -65,7 +90,10 @@ partial class ID2D1ShaderGenerator
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
// Compile the shader bytecode
|
||||
using ComPtr<ID3DBlob> dxcBlobBytecode = D2D1ShaderCompiler.Compile(hlslSource.AsSpan(), shaderProfile.Value, false);
|
||||
using ComPtr<ID3DBlob> dxcBlobBytecode = D2D1ShaderCompiler.Compile(
|
||||
sourceInfo.HlslSource.AsSpan(),
|
||||
sourceInfo.ShaderProfile.Value,
|
||||
sourceInfo.IsLinkingSupported);
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする