Refactor dynamic native libs tests

このコミットが含まれているのは:
Sergio Pedri committed 2022-06-25 14:49:15 +02:00
1 親 06cb67e490
コミット 318ff8d2c4
5ファイル変更
+50 -12

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

-8
ファイルの表示
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!-- This source is for the local NuGet packages, which are all generated in the centralized artifacts root folder -->
<add key="artifacts" value="..\..\artifacts" />
</packageSources>
</configuration>
@@ -11,4 +11,9 @@
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Project\*"/>
<None Include="Project\*"/>
</ItemGroup>
</Project>
+9 -2
ファイルの表示
@@ -19,17 +19,24 @@ public class NativeLibrariesResolverTests
{
string path = Path.GetDirectoryName(typeof(NativeLibrariesResolverTests).Assembly.Location)!;
while (Path.GetFileName(path) is not "ComputeSharp.Tests.NativeLibrariesResolver")
{
path = Path.GetDirectoryName(path)!;
}
SampleProjectDirectory = Path.Combine(path, "Project", "ComputeSharp.Sample.NuGet");
while (Path.GetFileName(path) is not "ComputeSharp")
{
path = Path.GetDirectoryName(path)!;
}
SampleProjectDirectory = Path.Combine(path, "samples", "ComputeSharp.Sample.NuGet");
string corePackagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Core", "ComputeSharp.Core.msbuildproj");
string packagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Package", "ComputeSharp.Package.msbuildproj");
string dynamicPackagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Dynamic.Package", "ComputeSharp.Dynamic.Package.msbuildproj");
// Run dotnet pack and on the packaging projects, to ensure the local NuGet packages are available
Process.Start("dotnet", $"pack {corePackagingProjectPath} -c Release").WaitForExit();
Process.Start("dotnet", $"pack {packagingProjectPath} -c Release").WaitForExit();
Process.Start("dotnet", $"pack {dynamicPackagingProjectPath} -c Release").WaitForExit();
}
@@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
<Platforms>AnyCPU;x64;ARM64</Platforms>
<RestoreSources>$(PackageOutputPath)</RestoreSources>
</PropertyGroup>
<ItemGroup>
@@ -12,6 +13,4 @@
<PackageReference Include="ComputeSharp.Dynamic" Version="$(PackageVersion)" />
</ItemGroup>
<Import Project="..\ComputeSharp.Sample.Shared\ComputeSharp.Sample.Shared.projitems" Label="Shared" />
</Project>
+35
ファイルの表示
@@ -0,0 +1,35 @@
using System.Diagnostics;
using System.Linq;
using ComputeSharp;
float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
// Create the graphics buffer
using ReadWriteBuffer<float> gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
// Run the shader
GraphicsDevice.Default.For(100, new MultiplyByTwo(gpuBuffer));
// Get the data back
float[] result = gpuBuffer.ToArray();
// Validate results
for (int i = 0; i < array.Length; i++)
{
Trace.Assert(result[i] == array[i] * 2);
}
/// <summary>
/// A sample kernel that requires dynamic compilation, as it's not precompiled.
/// </summary>
[AutoConstructor]
internal readonly partial struct MultiplyByTwo : IComputeShader
{
public readonly ReadWriteBuffer<float> buffer;
/// <inheritdoc/>
public void Execute()
{
buffer[ThreadIds.X] *= 2;
}
}