Merge pull request #165 from Sergio0694/feature/net-framework-tests
.NET Framework tests
このコミットが含まれているのは:
16ファイル変更
+177
-92
検索条件に一致するファイルはありません
@@ -7,7 +7,7 @@ jobs:
|
||||
# Build the ComputeSharp project directly. This is the project that
|
||||
# would be built when running any of the local samples or unit tests.
|
||||
build-project:
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Git checkout
|
||||
uses: actions/checkout@v2
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
run-tests:
|
||||
if: success()
|
||||
needs: [build-project]
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Git checkout
|
||||
uses: actions/checkout@v2
|
||||
@@ -47,6 +47,12 @@ jobs:
|
||||
- name: Run ComputeSharp.Tests.Internals (.NET Core 3.1)
|
||||
run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed"
|
||||
shell: cmd
|
||||
- name: Run ComputeSharp.Tests (.NET Framework 4.7.2)
|
||||
run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed"
|
||||
shell: cmd
|
||||
- name: Run ComputeSharp.Tests.Internals (.NET Framework 4.7.2)
|
||||
run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed"
|
||||
shell: cmd
|
||||
- name: Run ComputeSharp.Tests.SourceGenerators
|
||||
run: dotnet test tests\ComputeSharp.Tests.SourceGenerators\ComputeSharp.Tests.SourceGenerators.csproj -v n -l "console;verbosity=detailed"
|
||||
shell: cmd
|
||||
@@ -55,7 +61,7 @@ jobs:
|
||||
run-samples:
|
||||
if: success()
|
||||
needs: [run-tests]
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Git checkout
|
||||
uses: actions/checkout@v2
|
||||
@@ -79,6 +85,12 @@ jobs:
|
||||
- name: Run ComputeSharp.Sample (.NET Core 3.1)
|
||||
run: samples\ComputeSharp.Sample\bin\x64\Release\netcoreapp3.1\win-x64\ComputeSharp.Sample.exe
|
||||
shell: cmd
|
||||
- name: Build ComputeSharp.Sample (.NET Framework 4.7.2)
|
||||
run: dotnet build samples\ComputeSharp.Sample\ComputeSharp.Sample.csproj -c Release -f net472 /p:Platform=x64
|
||||
shell: cmd
|
||||
- name: Run ComputeSharp.Sample (.NET Framework 4.7.2)
|
||||
run: samples\ComputeSharp.Sample\bin\x64\Release\net472\ComputeSharp.Sample.exe
|
||||
shell: cmd
|
||||
- name: Build ComputeSharp.Sample.FSharp
|
||||
run: dotnet build samples\ComputeSharp.Sample.FSharp\ComputeSharp.Sample.FSharp.fsproj -c Release
|
||||
shell: cmd
|
||||
@@ -97,6 +109,12 @@ jobs:
|
||||
- name: Run ComputeSharp.ImageProcessing.csproj (.NET Core 3.1)
|
||||
run: samples\ComputeSharp.ImageProcessing\bin\x64\Release\netcoreapp3.1\win-x64\ComputeSharp.ImageProcessing.exe
|
||||
shell: cmd
|
||||
- name: Build ComputeSharp.ImageProcessing.csproj (.NET Framework 4.7.2)
|
||||
run: dotnet build samples\ComputeSharp.ImageProcessing\ComputeSharp.ImageProcessing.csproj -c Release -f net472 /p:Platform=x64
|
||||
shell: cmd
|
||||
- name: Run ComputeSharp.ImageProcessing.csproj (.NET Framework 4.7.2)
|
||||
run: samples\ComputeSharp.ImageProcessing\bin\x64\Release\net472\ComputeSharp.ImageProcessing.exe
|
||||
shell: cmd
|
||||
- name: Build ComputeSharp.Benchmark.csproj
|
||||
run: dotnet build samples\ComputeSharp.Benchmark\ComputeSharp.Benchmark.csproj -c Release
|
||||
shell: cmd
|
||||
@@ -107,7 +125,7 @@ jobs:
|
||||
# Buils the .msbuildproj project to generate the NuGet package.
|
||||
# This workflow also uploads the resulting package as an artifact.
|
||||
build-package:
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Git checkout
|
||||
uses: actions/checkout@v2
|
||||
@@ -130,7 +148,7 @@ jobs:
|
||||
verify-package:
|
||||
if: success()
|
||||
needs: [build-package]
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Git checkout
|
||||
uses: actions/checkout@v2
|
||||
@@ -158,6 +176,12 @@ jobs:
|
||||
- name: Run ComputeSharp.Sample.NuGet (.NET Core 3.1)
|
||||
run: samples\ComputeSharp.Sample.NuGet\bin\Release\netcoreapp3.1\win-x64\ComputeSharp.Sample.NuGet.exe
|
||||
shell: cmd
|
||||
- name: Build ComputeSharp.Sample.NuGet (.NET Framework 4.7.2)
|
||||
run: dotnet build samples\ComputeSharp.Sample.NuGet\ComputeSharp.Sample.NuGet.csproj -c Release -f net472 /p:Platform=x64
|
||||
shell: cmd
|
||||
- name: Run ComputeSharp.Sample.NuGet (.NET Framework 4.7.2)
|
||||
run: samples\ComputeSharp.Sample.NuGet\bin\x64\Release\net472\ComputeSharp.Sample.NuGet.exe
|
||||
shell: cmd
|
||||
|
||||
# Run the extra tests to validate a number of build and publishing configurations.
|
||||
# This is used to ensure the native dependencies can always be loaded correctly
|
||||
@@ -165,7 +189,7 @@ jobs:
|
||||
verify-libs:
|
||||
if: success()
|
||||
needs: [verify-package]
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- name: Git checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
+8
-8
@@ -112,26 +112,26 @@ Global
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|x64.Build.0 = Debug|x64
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|x64.Build.0 = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|x64.ActiveCfg = Release|x64
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|x64.Build.0 = Release|x64
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|x64.Build.0 = Debug|x64
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|x64.Build.0 = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|x64.ActiveCfg = Release|x64
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|x64.Build.0 = Release|x64
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -205,8 +205,8 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
|
||||
// Fill in the complex kernel values
|
||||
Unsafe.Add(ref baseRef, i) = new Complex64(
|
||||
MathF.Exp(-a * value) * MathF.Cos(b * value),
|
||||
MathF.Exp(-a * value) * MathF.Sin(b * value));
|
||||
(float)(Math.Exp(-a * value) * Math.Cos(b * value)),
|
||||
(float)(Math.Exp(-a * value) * Math.Sin(b * value)));
|
||||
}
|
||||
|
||||
return kernel;
|
||||
@@ -245,7 +245,7 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
}
|
||||
|
||||
// Normalize the kernels
|
||||
float scalar = 1f / MathF.Sqrt(total);
|
||||
float scalar = 1f / (float)Math.Sqrt(total);
|
||||
|
||||
for (int i = 0; i < kernelsSpan.Length; i++)
|
||||
{
|
||||
|
||||
@@ -80,13 +80,13 @@ public sealed partial class HlslGaussianBlurProcessor
|
||||
private static float Gaussian(float x, float sigma)
|
||||
{
|
||||
const float Numerator = 1.0f;
|
||||
float denominator = MathF.Sqrt(2 * MathF.PI) * sigma;
|
||||
float denominator = (float)(Math.Sqrt(2 * Math.PI) * sigma);
|
||||
|
||||
float exponentNumerator = -x * x;
|
||||
float exponentDenominator = 2 * sigma * sigma;
|
||||
|
||||
float left = Numerator / denominator;
|
||||
float right = MathF.Exp(exponentNumerator / exponentDenominator);
|
||||
float right = (float)Math.Exp(exponentNumerator / exponentDenominator);
|
||||
|
||||
return left * right;
|
||||
}
|
||||
|
||||
@@ -28,9 +28,16 @@ class Program
|
||||
using Image copy = image.Clone(c => c.ApplyProcessor(effect.Processor));
|
||||
|
||||
Console.WriteLine($">> Saving {effect.Name} to disk");
|
||||
string targetPath = Path.Combine(
|
||||
Path.GetRelativePath(Path.GetDirectoryName(path)!, @"..\..\..\"),
|
||||
$"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}");
|
||||
|
||||
string targetPath = Path.GetDirectoryName(path)!;
|
||||
|
||||
while (Path.GetFileName(targetPath) != "ComputeSharp.ImageProcessing")
|
||||
{
|
||||
targetPath = Path.GetDirectoryName(targetPath)!;
|
||||
}
|
||||
|
||||
targetPath = Path.Combine(targetPath, $"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}");
|
||||
|
||||
copy.Save(targetPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ partial class Program
|
||||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
var row = array[(i * width)..((i + 1) * width)];
|
||||
var row = array.AsSpan(i * width, width).ToArray();
|
||||
var text = string.Join(",", row.Select(x => x.ToString(CultureInfo.InvariantCulture).PadLeft(numberWidth)));
|
||||
|
||||
Console.WriteLine(text);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using ComputeSharp.Exceptions;
|
||||
using System;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Shaders.Translation;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TerraFX.Interop.DirectX;
|
||||
@@ -32,7 +33,7 @@ public class ShaderCompilerTests
|
||||
[TestMethod]
|
||||
public void CompileTest_Ok()
|
||||
{
|
||||
using ComPtr<IDxcBlob> dxcBlob = ShaderCompiler.Instance.CompileShader(ShaderSource);
|
||||
using ComPtr<IDxcBlob> dxcBlob = ShaderCompiler.Instance.CompileShader(ShaderSource.AsSpan());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -41,6 +42,6 @@ public class ShaderCompilerTests
|
||||
{
|
||||
var faultyShader = ShaderSource.Replace("ids.x", "ids.X");
|
||||
|
||||
using ComPtr<IDxcBlob> dxcBlob = ShaderCompiler.Instance.CompileShader(faultyShader);
|
||||
using ComPtr<IDxcBlob> dxcBlob = ShaderCompiler.Instance.CompileShader(faultyShader.AsSpan());
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -23,13 +24,13 @@
|
||||
|
||||
<!-- When the .NET Standard 2.0 version of ComputeSharp is resolved, the TerraFX APIs are internal, as they
|
||||
are referenced from the shared project. The same reference is needed here to make all tests build fine. -->
|
||||
<Import Condition="'$(TargetFramework)' == 'netcoreapp3.1'"
|
||||
<Import Condition="'$(TargetFramework)' != 'net6.0'"
|
||||
Project="..\..\src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems" />
|
||||
<Import Condition="'$(TargetFramework)' == 'netcoreapp3.1'"
|
||||
<Import Condition="'$(TargetFramework)' != 'net6.0'"
|
||||
Project="..\..\src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems" />
|
||||
|
||||
<!-- Only when the local TerraFX is referenced, ignore warnings from there -->
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<PropertyGroup Condition="'$(TargetFramework)' != 'net6.0'">
|
||||
<NoWarn>$(NoWarn);CS0649</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#if !NETCOREAPP3_1_OR_GREATER
|
||||
|
||||
namespace System;
|
||||
|
||||
/// <summary>
|
||||
/// A type with some helper methods for the <see cref="Random"/> class.
|
||||
/// </summary>
|
||||
internal static class RandomExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Fills the elements of a specified span of bytes with random numbers.
|
||||
/// </summary>
|
||||
/// <param name="random">The target random instance.</param>
|
||||
/// <param name="buffer">The array to be filled with random numbers.</param>
|
||||
public static void NextBytes(this Random random, Span<byte> buffer)
|
||||
{
|
||||
byte[] array = new byte[buffer.Length];
|
||||
|
||||
random.NextBytes(array);
|
||||
|
||||
array.AsSpan().CopyTo(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -203,20 +203,26 @@ public partial class Texture3DTests
|
||||
[Data(0, 60, 2, 64, 4, 1)]
|
||||
[Data(63, 2, 0, 1, 60, 2)]
|
||||
[Data(2, 63, 1, 60, 1, 2)]
|
||||
public void GetData_RangeToVoid_Ok(Device device, Type textureType, int x, int y, int z, int width, int height, int depth)
|
||||
public unsafe void GetData_RangeToVoid_Ok(Device device, Type textureType, int x, int y, int z, int width, int height, int depth)
|
||||
{
|
||||
int[,,] array = new int[3, 64, 64];
|
||||
|
||||
foreach (var item in array.AsSpan().Enumerate())
|
||||
fixed (int* p = array)
|
||||
{
|
||||
item.Value = item.Index;
|
||||
foreach (var item in new Span<int>(p, array.Length).Enumerate())
|
||||
{
|
||||
item.Value = item.Index;
|
||||
}
|
||||
}
|
||||
|
||||
using Texture3D<int> texture = device.Get().AllocateTexture3D(textureType, array);
|
||||
|
||||
int[,,] result = new int[depth, height, width];
|
||||
|
||||
texture.CopyTo(result.AsSpan(), x, y, z, width, height, depth);
|
||||
fixed (int* p = result)
|
||||
{
|
||||
texture.CopyTo(new Span<int>(p, result.Length), x, y, z, width, height, depth);
|
||||
}
|
||||
|
||||
for (int k = 0; k < depth; k++)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Tests.Attributes;
|
||||
using ComputeSharp.Tests.Extensions;
|
||||
@@ -97,7 +98,7 @@ public partial class TransferTexture2DTests
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
public void Allocate_UploadTexture2D_Copy_Full(Device device)
|
||||
public unsafe void Allocate_UploadTexture2D_Copy_Full(Device device)
|
||||
{
|
||||
using UploadTexture2D<int> uploadTexture2D = device.Get().AllocateUploadTexture2D<int>(256, 256);
|
||||
|
||||
@@ -115,9 +116,12 @@ public partial class TransferTexture2DTests
|
||||
Assert.AreEqual(uploadTexture2D.Width, result.GetLength(1));
|
||||
Assert.AreEqual(uploadTexture2D.Height, result.GetLength(0));
|
||||
|
||||
for (int i = 0; i < uploadTexture2D.Height; i++)
|
||||
fixed (int* _ = result)
|
||||
{
|
||||
Assert.IsTrue(uploadTexture2D.View.GetRowSpan(i).SequenceEqual(result.GetRowSpan(i)));
|
||||
for (int i = 0; i < uploadTexture2D.Height; i++)
|
||||
{
|
||||
Assert.IsTrue(uploadTexture2D.View.GetRowSpan(i).SequenceEqual(new Span<int>(Unsafe.AsPointer(ref result[i, 0]), result.GetLength(1))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +131,7 @@ public partial class TransferTexture2DTests
|
||||
[Data(128, 0, 1813, 2048)]
|
||||
[Data(0, 128, 2000, 944)]
|
||||
[Data(97, 33, 512, 794)]
|
||||
public void Allocate_UploadTexture2D_Copy_Range(Device device, int x, int y, int width, int height)
|
||||
public unsafe void Allocate_UploadTexture2D_Copy_Range(Device device, int x, int y, int width, int height)
|
||||
{
|
||||
using UploadTexture2D<int> uploadTexture2D = device.Get().AllocateUploadTexture2D<int>(2048, 2048);
|
||||
|
||||
@@ -142,24 +146,27 @@ public partial class TransferTexture2DTests
|
||||
|
||||
int[,] result = readOnlyTexture2D.ToArray();
|
||||
|
||||
for (int i = 0; i < height; i++)
|
||||
fixed (void* _ = result)
|
||||
{
|
||||
Span<int> sourceRow = uploadTexture2D.View.GetRowSpan(i + y).Slice(x, width);
|
||||
Span<int> destinationRow = result.GetRowSpan(i).Slice(0, width);
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
Span<int> sourceRow = uploadTexture2D.View.GetRowSpan(i + y).Slice(x, width);
|
||||
Span<int> destinationRow = new Span<int>(Unsafe.AsPointer(ref result[i, 0]), result.GetLength(1)).Slice(0, width);
|
||||
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
public void Allocate_ReadBackTexture2D_Copy_Full(Device device)
|
||||
public unsafe void Allocate_ReadBackTexture2D_Copy_Full(Device device)
|
||||
{
|
||||
int[,] source = new int[256, 256];
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
fixed (int* p = source)
|
||||
{
|
||||
new Random(42).NextBytes(source.GetRowSpan(i).AsBytes());
|
||||
new Random(42).NextBytes(new Span<int>(p, source.Length).AsBytes());
|
||||
}
|
||||
|
||||
using ReadOnlyTexture2D<int> readOnlyTexture2D = device.Get().AllocateReadOnlyTexture2D(source);
|
||||
@@ -170,9 +177,12 @@ public partial class TransferTexture2DTests
|
||||
Assert.AreEqual(readBackTexture2D.Width, 256);
|
||||
Assert.AreEqual(readBackTexture2D.Height, 256);
|
||||
|
||||
for (int i = 0; i < readBackTexture2D.Height; i++)
|
||||
fixed (int* p = source)
|
||||
{
|
||||
Assert.IsTrue(readBackTexture2D.View.GetRowSpan(i).SequenceEqual(source.GetRowSpan(i)));
|
||||
for (int i = 0; i < readBackTexture2D.Height; i++)
|
||||
{
|
||||
Assert.IsTrue(readBackTexture2D.View.GetRowSpan(i).SequenceEqual(new Span<int>(Unsafe.AsPointer(ref source[i, 0]), source.GetLength(1))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,13 +192,13 @@ public partial class TransferTexture2DTests
|
||||
[Data(128, 0, 1813, 2048)]
|
||||
[Data(0, 128, 2000, 944)]
|
||||
[Data(97, 33, 512, 794)]
|
||||
public void Allocate_ReadBackTexture2D_Copy_Range(Device device, int x, int y, int width, int height)
|
||||
public unsafe void Allocate_ReadBackTexture2D_Copy_Range(Device device, int x, int y, int width, int height)
|
||||
{
|
||||
int[,] source = new int[2048, 2048];
|
||||
|
||||
for (int i = 0; i < 2048; i++)
|
||||
fixed (int* p = source)
|
||||
{
|
||||
new Random(42).NextBytes(source.GetRowSpan(i).AsBytes());
|
||||
new Random(42).NextBytes(new Span<int>(p, source.Length).AsBytes());
|
||||
}
|
||||
|
||||
using ReadOnlyTexture2D<int> readOnlyTexture2D = device.Get().AllocateReadOnlyTexture2D(source);
|
||||
@@ -196,12 +206,15 @@ public partial class TransferTexture2DTests
|
||||
|
||||
readOnlyTexture2D.CopyTo(readBackTexture2D, x, y, width, height);
|
||||
|
||||
for (int i = 0; i < height; i++)
|
||||
fixed (int* p = source)
|
||||
{
|
||||
Span<int> sourceRow = source.GetRowSpan(i + y).Slice(x, width);
|
||||
Span<int> destinationRow = readBackTexture2D.View.GetRowSpan(i).Slice(0, width);
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
Span<int> sourceRow = new Span<int>(Unsafe.AsPointer(ref source[i + y, 0]), source.GetLength(1)).Slice(x, width);
|
||||
Span<int> destinationRow = readBackTexture2D.View.GetRowSpan(i).Slice(0, width);
|
||||
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Resources;
|
||||
using ComputeSharp.Tests.Attributes;
|
||||
using ComputeSharp.Tests.Extensions;
|
||||
@@ -104,7 +105,7 @@ public partial class TransferTexture3DTests
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
public void Allocate_UploadTexture3D_Copy_Full(Device device)
|
||||
public unsafe void Allocate_UploadTexture3D_Copy_Full(Device device)
|
||||
{
|
||||
using UploadTexture3D<int> uploadTexture3D = device.Get().AllocateUploadTexture3D<int>(256, 256, 16);
|
||||
|
||||
@@ -126,14 +127,17 @@ public partial class TransferTexture3DTests
|
||||
Assert.AreEqual(uploadTexture3D.Height, result.GetLength(1));
|
||||
Assert.AreEqual(uploadTexture3D.Depth, result.GetLength(0));
|
||||
|
||||
for (int i = 0; i < uploadTexture3D.Depth; i++)
|
||||
fixed (int* p = result)
|
||||
{
|
||||
for (int j = 0; j < uploadTexture3D.Height; j++)
|
||||
for (int i = 0; i < uploadTexture3D.Depth; i++)
|
||||
{
|
||||
Span<int> sourceRow = uploadTexture3D.View.GetRowSpan(j, i);
|
||||
Span<int> destinationRow = result.AsSpan2D(i).GetRowSpan(j);
|
||||
for (int j = 0; j < uploadTexture3D.Height; j++)
|
||||
{
|
||||
Span<int> sourceRow = uploadTexture3D.View.GetRowSpan(j, i);
|
||||
Span<int> destinationRow = new(Unsafe.AsPointer(ref result[i, j, 0]), result.GetLength(2));
|
||||
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,7 +149,7 @@ public partial class TransferTexture3DTests
|
||||
[Data(0, 128, 0, 189, 67, 8)]
|
||||
[Data(0, 0, 15, 32, 64, 1)]
|
||||
[Data(97, 33, 4, 128, 99, 7)]
|
||||
public void Allocate_UploadTexture3D_Copy_Range(Device device, int x, int y, int z, int width, int height, int depth)
|
||||
public unsafe void Allocate_UploadTexture3D_Copy_Range(Device device, int x, int y, int z, int width, int height, int depth)
|
||||
{
|
||||
using UploadTexture3D<int> uploadTexture3D = device.Get().AllocateUploadTexture3D<int>(256, 256, 16);
|
||||
|
||||
@@ -163,30 +167,30 @@ public partial class TransferTexture3DTests
|
||||
|
||||
int[,,] result = readOnlyTexture3D.ToArray();
|
||||
|
||||
for (int i = 0; i < depth; i++)
|
||||
fixed (int* p = result)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
for (int i = 0; i < depth; i++)
|
||||
{
|
||||
Span<int> sourceRow = uploadTexture3D.View.GetRowSpan(j + y, i + z).Slice(x, width);
|
||||
Span<int> destinationRow = result.AsSpan2D(i).GetRowSpan(j).Slice(0, width);
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
Span<int> sourceRow = uploadTexture3D.View.GetRowSpan(j + y, i + z).Slice(x, width);
|
||||
Span<int> destinationRow = new Span<int>(Unsafe.AsPointer(ref result[i, j, 0]), result.GetLength(2)).Slice(0, width);
|
||||
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
public void Allocate_ReadBackTexture3D_Copy_Full(Device device)
|
||||
public unsafe void Allocate_ReadBackTexture3D_Copy_Full(Device device)
|
||||
{
|
||||
int[,,] source = new int[16, 256, 256];
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
fixed (int* p = source)
|
||||
{
|
||||
for (int j = 0; j < 256; j++)
|
||||
{
|
||||
new Random(i * 5381 + j).NextBytes(source.AsSpan2D(i).GetRowSpan(j).AsBytes());
|
||||
}
|
||||
new Random(42).NextBytes(new Span<int>(p, source.Length).AsBytes());
|
||||
}
|
||||
|
||||
using ReadOnlyTexture3D<int> readOnlyTexture3D = device.Get().AllocateReadOnlyTexture3D(source);
|
||||
@@ -198,14 +202,17 @@ public partial class TransferTexture3DTests
|
||||
Assert.AreEqual(readBackTexture3D.Height, 256);
|
||||
Assert.AreEqual(readBackTexture3D.Depth, 16);
|
||||
|
||||
for (int i = 0; i < readBackTexture3D.Depth; i++)
|
||||
fixed (int* p = source)
|
||||
{
|
||||
for (int j = 0; j < readBackTexture3D.Height; j++)
|
||||
for (int i = 0; i < readBackTexture3D.Depth; i++)
|
||||
{
|
||||
Span<int> sourceRow = source.AsSpan2D(i).GetRowSpan(j);
|
||||
Span<int> destinationRow = readBackTexture3D.View.GetRowSpan(j, i);
|
||||
for (int j = 0; j < readBackTexture3D.Height; j++)
|
||||
{
|
||||
Span<int> sourceRow = new(Unsafe.AsPointer(ref source[i, j, 0]), source.GetLength(2));
|
||||
Span<int> destinationRow = readBackTexture3D.View.GetRowSpan(j, i);
|
||||
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,16 +224,13 @@ public partial class TransferTexture3DTests
|
||||
[Data(0, 128, 0, 189, 67, 8)]
|
||||
[Data(0, 0, 15, 32, 64, 1)]
|
||||
[Data(97, 33, 4, 128, 99, 7)]
|
||||
public void Allocate_ReadBackTexture3D_Copy_Range(Device device, int x, int y, int z, int width, int height, int depth)
|
||||
public unsafe void Allocate_ReadBackTexture3D_Copy_Range(Device device, int x, int y, int z, int width, int height, int depth)
|
||||
{
|
||||
int[,,] source = new int[16, 256, 256];
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
fixed (int* p = source)
|
||||
{
|
||||
for (int j = 0; j < 256; j++)
|
||||
{
|
||||
new Random(i * 5381 + j).NextBytes(source.AsSpan2D(i).GetRowSpan(j).AsBytes());
|
||||
}
|
||||
new Random(42).NextBytes(new Span<int>(p, source.Length).AsBytes());
|
||||
}
|
||||
|
||||
using ReadOnlyTexture3D<int> readOnlyTexture3D = device.Get().AllocateReadOnlyTexture3D(source);
|
||||
@@ -234,14 +238,17 @@ public partial class TransferTexture3DTests
|
||||
|
||||
readOnlyTexture3D.CopyTo(readBackTexture3D, x, y, z, width, height, depth);
|
||||
|
||||
for (int i = 0; i < depth; i++)
|
||||
fixed (int* p = source)
|
||||
{
|
||||
for (int j = 0; j < height; j++)
|
||||
for (int i = 0; i < depth; i++)
|
||||
{
|
||||
Span<int> sourceRow = source.AsSpan2D(i + z).GetRowSpan(j + y).Slice(x, width);
|
||||
Span<int> destinationRow = readBackTexture3D.View.GetRowSpan(j, i).Slice(0, width);
|
||||
for (int j = 0; j < height; j++)
|
||||
{
|
||||
Span<int> sourceRow = new Span<int>(Unsafe.AsPointer(ref source[i + z, j + y, 0]), source.GetLength(2)).Slice(x, width);
|
||||
Span<int> destinationRow = readBackTexture3D.View.GetRowSpan(j, i).Slice(0, width);
|
||||
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする