Add .NET Framework 4.7.2 target to test projects

このコミットが含まれているのは:
Sergio Pedri committed 2021-11-18 01:16:30 +01:00
1 親 d7a94fdf37
コミット f13253dfdb
9ファイル変更
+123 -71

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

+3 -3
ファイルの表示
@@ -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++)
{
+2 -2
ファイルの表示
@@ -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;
}
+1 -1
ファイルの表示
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
+4 -3
ファイルの表示
@@ -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());
}
}
+4 -4
ファイルの表示
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
@@ -23,13 +23,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>
+25
ファイルの表示
@@ -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
+10 -4
ファイルの表示
@@ -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++)
{
+33 -20
ファイルの表示
@@ -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));
}
}
}
}
+41 -34
ファイルの表示
@@ -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));
}
}
}
}