Switched generated methods to explicit interface implementations
このコミットが含まれているのは:
1 親
56b326a6e4
コミット
bbb42e5367
6ファイル変更
+37
-34
検索条件に一致するファイルはありません
@@ -79,7 +79,7 @@ namespace ComputeSharp.SourceGenerators
|
||||
|
||||
// This code produces a method declaration as follows:
|
||||
//
|
||||
// public readonly void BuildHlslString(ref ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ)
|
||||
// readonly void IShader.BuildHlslString(ref ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ)
|
||||
// {
|
||||
// <BODY>
|
||||
// }
|
||||
@@ -87,7 +87,8 @@ namespace ComputeSharp.SourceGenerators
|
||||
MethodDeclaration(
|
||||
PredefinedType(Token(SyntaxKind.VoidKeyword)),
|
||||
Identifier("BuildHlslString"))
|
||||
.AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ReadOnlyKeyword))
|
||||
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName(nameof(IShader))))
|
||||
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
|
||||
.AddParameterListParameters(
|
||||
Parameter(Identifier("builder")).AddModifiers(Token(SyntaxKind.OutKeyword)).WithType(IdentifierName("ArrayPoolStringBuilder")),
|
||||
Parameter(Identifier("threadsX")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using ComputeSharp.__Internals;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.SourceGenerators
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
@@ -17,7 +20,7 @@ namespace ComputeSharp.SourceGenerators
|
||||
{
|
||||
// This code produces a method declaration as follows:
|
||||
//
|
||||
// public readonly int GetDispatchId()
|
||||
// readonly int IShader.GetDispatchId()
|
||||
// {
|
||||
// <BODY>
|
||||
// }
|
||||
@@ -25,7 +28,8 @@ namespace ComputeSharp.SourceGenerators
|
||||
MethodDeclaration(
|
||||
PredefinedType(Token(SyntaxKind.IntKeyword)),
|
||||
Identifier("GetDispatchId"))
|
||||
.AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ReadOnlyKeyword))
|
||||
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName(nameof(IShader))))
|
||||
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
|
||||
.WithBody(GetShaderHashCodeBody(structDeclarationSymbol));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Core.Helpers;
|
||||
using ComputeSharp.SourceGenerators.Diagnostics;
|
||||
using ComputeSharp.SourceGenerators.Extensions;
|
||||
@@ -11,6 +12,8 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using static ComputeSharp.SourceGenerators.Diagnostics.DiagnosticDescriptors;
|
||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.SourceGenerators
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
@@ -25,8 +28,7 @@ namespace ComputeSharp.SourceGenerators
|
||||
{
|
||||
// This code produces a method declaration as follows:
|
||||
//
|
||||
// public readonly void LoadDispatchData<TDataLoader>(ref TDataLoader loader, GraphicsDevice device, int x, int y, int z)
|
||||
// where TDataLoader : struct, IDispatchDataLoader
|
||||
// readonly void IShader.LoadDispatchData<TDataLoader>(ref TDataLoader loader, GraphicsDevice device, int x, int y, int z)
|
||||
// {
|
||||
// <BODY>
|
||||
// }
|
||||
@@ -34,7 +36,8 @@ namespace ComputeSharp.SourceGenerators
|
||||
MethodDeclaration(
|
||||
PredefinedType(Token(SyntaxKind.VoidKeyword)),
|
||||
Identifier("LoadDispatchData"))
|
||||
.AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ReadOnlyKeyword))
|
||||
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName(nameof(IShader))))
|
||||
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
|
||||
.AddTypeParameterListParameters(TypeParameter(Identifier("TDataLoader")))
|
||||
.AddParameterListParameters(
|
||||
Parameter(Identifier("loader"))
|
||||
@@ -44,11 +47,6 @@ namespace ComputeSharp.SourceGenerators
|
||||
Parameter(Identifier("x")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
|
||||
Parameter(Identifier("y")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
|
||||
Parameter(Identifier("z")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))))
|
||||
.AddConstraintClauses(
|
||||
TypeParameterConstraintClause(IdentifierName("TDataLoader"))
|
||||
.AddConstraints(
|
||||
ClassOrStructConstraint(SyntaxKind.StructConstraint),
|
||||
TypeConstraint(IdentifierName("IDispatchDataLoader"))))
|
||||
.WithBody(Block(GetDispatchDataLoadingStatements(context, structDeclarationSymbol, out discoveredResources, out root32BitConstantsCount)));
|
||||
}
|
||||
|
||||
|
||||
+6
-8
@@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.SourceGenerators.Mappings;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.SourceGenerators
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
@@ -19,8 +22,7 @@ namespace ComputeSharp.SourceGenerators
|
||||
{
|
||||
// This code produces a method declaration as follows:
|
||||
//
|
||||
// public readonly void LoadDispatchMetadata<TMetadataLoader>(ref TMetadataLoader loader, out IntPtr result)
|
||||
// where TMetadataLoader : struct, IDispatchMetadataLoader
|
||||
// readonly void IShader.LoadDispatchMetadata<TMetadataLoader>(ref TMetadataLoader loader, out IntPtr result)
|
||||
// {
|
||||
// <BODY>
|
||||
// }
|
||||
@@ -28,7 +30,8 @@ namespace ComputeSharp.SourceGenerators
|
||||
MethodDeclaration(
|
||||
PredefinedType(Token(SyntaxKind.VoidKeyword)),
|
||||
Identifier("LoadDispatchMetadata"))
|
||||
.AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ReadOnlyKeyword))
|
||||
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName(nameof(IShader))))
|
||||
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
|
||||
.AddTypeParameterListParameters(TypeParameter(Identifier("TMetadataLoader")))
|
||||
.AddParameterListParameters(
|
||||
Parameter(Identifier("loader"))
|
||||
@@ -37,11 +40,6 @@ namespace ComputeSharp.SourceGenerators
|
||||
Parameter(Identifier("result"))
|
||||
.AddModifiers(Token(SyntaxKind.OutKeyword))
|
||||
.WithType(IdentifierName(typeof(IntPtr).Name)))
|
||||
.AddConstraintClauses(
|
||||
TypeParameterConstraintClause(IdentifierName("TMetadataLoader"))
|
||||
.AddConstraints(
|
||||
ClassOrStructConstraint(SyntaxKind.StructConstraint),
|
||||
TypeConstraint(IdentifierName("IDispatchMetadataLoader"))))
|
||||
.WithBody(Block(GetDispatchMetadataLoadingStatements(implicitTextureType, discoveredResources, root32BitConstantsCount, isSamplerUsed)));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using ComputeSharp.Tests.Internals.Helpers;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Tests.Internals.Helpers;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
@@ -26,7 +27,7 @@ namespace ComputeSharp.Tests.Internals
|
||||
|
||||
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
|
||||
|
||||
new CapturedResourceShader(buffer).LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
((IShader)new CapturedResourceShader(buffer)).LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(3, dataLoader.Values.Length);
|
||||
Assert.AreEqual(1, dataLoader.Resources.Length);
|
||||
@@ -59,7 +60,7 @@ namespace ComputeSharp.Tests.Internals
|
||||
|
||||
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
|
||||
|
||||
new MultipleResourcesAndPrimitivesShader(buffer0, buffer1, 1, 22, 77).LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
((IShader)new MultipleResourcesAndPrimitivesShader(buffer0, buffer1, 1, 22, 77)).LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(6, dataLoader.Values.Length);
|
||||
Assert.AreEqual(2, dataLoader.Resources.Length);
|
||||
@@ -98,7 +99,7 @@ namespace ComputeSharp.Tests.Internals
|
||||
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
|
||||
ScalarAndVectorTypesShader shader = new(buffer, new(55, 44, 888), 22, 77, new(3.14, 6.28), 42, 9999);
|
||||
|
||||
shader.LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
((IShader)shader).LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(18, dataLoader.Values.Length);
|
||||
Assert.AreEqual(1, dataLoader.Resources.Length);
|
||||
@@ -160,7 +161,7 @@ namespace ComputeSharp.Tests.Internals
|
||||
i2x2: new(11, 22, 33, 44),
|
||||
d: 9999);
|
||||
|
||||
shader.LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
((IShader)shader).LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(31, dataLoader.Values.Length);
|
||||
Assert.AreEqual(1, dataLoader.Resources.Length);
|
||||
@@ -240,7 +241,7 @@ namespace ComputeSharp.Tests.Internals
|
||||
i2x2: new(11, 22, 33, 44),
|
||||
d: 9999));
|
||||
|
||||
shader.LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
((IShader)shader).LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(31, dataLoader.Values.Length);
|
||||
Assert.AreEqual(1, dataLoader.Resources.Length);
|
||||
@@ -344,7 +345,7 @@ namespace ComputeSharp.Tests.Internals
|
||||
a: 888888,
|
||||
b: new(333.3f, 444.4f))));
|
||||
|
||||
shader.LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
((IShader)shader).LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(47, dataLoader.Values.Length);
|
||||
Assert.AreEqual(1, dataLoader.Resources.Length);
|
||||
@@ -425,7 +426,7 @@ namespace ComputeSharp.Tests.Internals
|
||||
|
||||
DebugDispatchDataLoader dataLoader = DebugDispatchDataLoader.Create();
|
||||
|
||||
new AmbiguousNamesShader(a, b, c, x, y, z, 7777, 8888, 9999).LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
((IShader)new AmbiguousNamesShader(a, b, c, x, y, z, 7777, 8888, 9999)).LoadDispatchData(ref dataLoader, Gpu.Default, 111, 222, 333);
|
||||
|
||||
Assert.AreEqual(6, dataLoader.Values.Length);
|
||||
Assert.AreEqual(6, dataLoader.Resources.Length);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ComputeSharp.__Internals;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
@@ -29,14 +30,14 @@ namespace ComputeSharp.Tests.Internals
|
||||
Shader1 shader1 = new() { A = value, B = buffer };
|
||||
|
||||
int
|
||||
hash1 = shader1.GetDispatchId(),
|
||||
hash2 = shader1.GetDispatchId();
|
||||
hash1 = ((IShader)shader1).GetDispatchId(),
|
||||
hash2 = ((IShader)shader1).GetDispatchId();
|
||||
|
||||
Assert.IsTrue(hash1 == hash2);
|
||||
|
||||
Shader1 shader2 = new() { A = value, B = buffer };
|
||||
|
||||
int hash3 = shader2.GetDispatchId();
|
||||
int hash3 = ((IShader)shader2).GetDispatchId();
|
||||
|
||||
Assert.IsTrue(hash1 == hash3);
|
||||
}
|
||||
@@ -63,8 +64,8 @@ namespace ComputeSharp.Tests.Internals
|
||||
Shader2 shader1 = new() { A = 1, B = buffer, F = f };
|
||||
|
||||
int
|
||||
hash1 = shader1.GetDispatchId(),
|
||||
hash2 = shader1.GetDispatchId();
|
||||
hash1 = ((IShader)shader1).GetDispatchId(),
|
||||
hash2 = ((IShader)shader1).GetDispatchId();
|
||||
|
||||
Assert.IsTrue(hash1 == hash2);
|
||||
|
||||
@@ -72,7 +73,7 @@ namespace ComputeSharp.Tests.Internals
|
||||
|
||||
Shader2 shader2 = new() { A = 1, B = buffer, F = f };
|
||||
|
||||
int hash3 = shader2.GetDispatchId();
|
||||
int hash3 = ((IShader)shader2).GetDispatchId();
|
||||
|
||||
Assert.IsFalse(hash1 == hash3);
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする