Fix selected profile check for ebedded bytecode
このコミットが含まれているのは:
1 親
4652a5a1cd
コミット
13aa9db1db
3ファイル変更
+11
-11
検索条件に一致するファイルはありません
+3
-6
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.D2D1Interop.__Internals;
|
||||
using ComputeSharp.D2D1Interop.SourceGenerators.Models;
|
||||
@@ -78,7 +77,7 @@ partial class ID2D1ShaderGenerator
|
||||
Argument(IdentifierName("loader")).WithRefKindKeyword(Token(SyntaxKind.RefKeyword)),
|
||||
Argument(ThisExpression()).WithRefKindKeyword(Token(SyntaxKind.InKeyword)),
|
||||
Argument(IdentifierName("shaderProfile")),
|
||||
Argument(LiteralExpression(bytecodeInfo.isLinkingSupported ? SyntaxKind.TrueLiteralExpression : SyntaxKind.FalseLiteralExpression))));
|
||||
Argument(LiteralExpression(bytecodeInfo.IsLinkingSupported ? SyntaxKind.TrueLiteralExpression : SyntaxKind.FalseLiteralExpression))));
|
||||
|
||||
// If there is no precompiled bytecode, just return the dynamic path
|
||||
if (bytecodeInfo.Bytecode.IsDefaultOrEmpty)
|
||||
@@ -88,8 +87,6 @@ partial class ID2D1ShaderGenerator
|
||||
return Block(dynamicLoadingStatement);
|
||||
}
|
||||
|
||||
ImmutableArray<StatementSyntax>.Builder statements = ImmutableArray.CreateBuilder<StatementSyntax>();
|
||||
|
||||
bytecodeLiterals = BuildShaderBytecodeExpressionString(bytecodeInfo.Bytecode.AsSpan());
|
||||
|
||||
// This code produces a branch as follows:
|
||||
@@ -113,8 +110,8 @@ partial class ID2D1ShaderGenerator
|
||||
ConstantPattern(
|
||||
MemberAccessExpression(
|
||||
SyntaxKind.SimpleMemberAccessExpression,
|
||||
IdentifierName(nameof(D2D1ShaderProfile)),
|
||||
IdentifierName(D2D1ShaderProfile.PixelShader50.ToString()))))),
|
||||
IdentifierName("global::ComputeSharp.D2D1Interop.D2D1ShaderProfile"),
|
||||
IdentifierName(bytecodeInfo.ShaderProfile.GetValueOrDefault().ToString()))))),
|
||||
Block(
|
||||
LocalDeclarationStatement(
|
||||
VariableDeclaration(
|
||||
|
||||
@@ -147,7 +147,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
EmbeddedBytecodeInfo bytecodeInfo = new(item.Source.HlslSource, item.Source.IsLinkingSupported, bytecode);
|
||||
EmbeddedBytecodeInfo bytecodeInfo = new(item.Source.HlslSource, item.Source.ShaderProfile, item.Source.IsLinkingSupported, bytecode);
|
||||
|
||||
return (item.Hierarchy, bytecodeInfo, diagnostic);
|
||||
});
|
||||
|
||||
@@ -9,9 +9,10 @@ namespace ComputeSharp.D2D1Interop.SourceGenerators.Models;
|
||||
/// A model representing a shared and its compiled bytecode, if available.
|
||||
/// </summary>
|
||||
/// <param name="HlslSource">The HLSL source for the shader.</param>
|
||||
/// <param name="isLinkingSupported">Whether linking is supported for the current shader.</param>
|
||||
/// <param name="ShaderProfile">The shader profile to use to compile the shader, if requested.</param>
|
||||
/// <param name="IsLinkingSupported">Whether linking is supported for the current shader.</param>
|
||||
/// <param name="Bytecode">The compiled shader bytecode, if available.</param>
|
||||
internal sealed record EmbeddedBytecodeInfo(string HlslSource, bool isLinkingSupported, ImmutableArray<byte> Bytecode)
|
||||
internal sealed record EmbeddedBytecodeInfo(string HlslSource, D2D1ShaderProfile? ShaderProfile, bool IsLinkingSupported, ImmutableArray<byte> Bytecode)
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="EmbeddedBytecodeInfo"/>.
|
||||
@@ -43,7 +44,8 @@ internal sealed record EmbeddedBytecodeInfo(string HlslSource, bool isLinkingSup
|
||||
|
||||
return
|
||||
x.HlslSource == y.HlslSource &&
|
||||
x.isLinkingSupported == y.isLinkingSupported &&
|
||||
x.ShaderProfile == y.ShaderProfile &&
|
||||
x.IsLinkingSupported == y.IsLinkingSupported &&
|
||||
x.Bytecode.SequenceEqual(y.Bytecode);
|
||||
}
|
||||
|
||||
@@ -53,7 +55,8 @@ internal sealed record EmbeddedBytecodeInfo(string HlslSource, bool isLinkingSup
|
||||
HashCode hashCode = default;
|
||||
|
||||
hashCode.Add(obj.HlslSource);
|
||||
hashCode.Add(obj.isLinkingSupported);
|
||||
hashCode.Add(obj.ShaderProfile);
|
||||
hashCode.Add(obj.IsLinkingSupported);
|
||||
hashCode.AddBytes(obj.Bytecode.AsSpan());
|
||||
|
||||
return hashCode.ToHashCode();
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする