Skip to content

Commit

Permalink
Cross target NET472 and enable extended intrinisics behind SUPPORTS_E…
Browse files Browse the repository at this point in the history
…XTENDED_INTRINSICS symbol
  • Loading branch information
iamcarbon committed Oct 24, 2018
1 parent 62396c0 commit f52be32
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
Expand All @@ -20,8 +19,7 @@ internal static partial class SimdUtils
public static class ExtendedIntrinsics
{
public static bool IsAvailable { get; } =
#if NETCOREAPP2_1
// TODO: Also available in .NET 4.7.2, we need to add a build target!
#if SUPPORTS_EXTENDED_INTRINSICS
Vector.IsHardwareAccelerated;
#else
false;
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/Common/Helpers/SimdUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal static void BulkConvertByteToNormalizedFloat(ReadOnlySpan<byte> source,
{
DebugGuard.IsTrue(source.Length == dest.Length, nameof(source), "Input spans must be of same length!");

#if NETCOREAPP2_1
#if SUPPORTS_EXTENDED_INTRINSICS
ExtendedIntrinsics.BulkConvertByteToNormalizedFloatReduce(ref source, ref dest);
#else
BasicIntrinsics256.BulkConvertByteToNormalizedFloatReduce(ref source, ref dest);
Expand All @@ -94,7 +94,7 @@ internal static void BulkConvertNormalizedFloatToByteClampOverflows(ReadOnlySpan
{
DebugGuard.IsTrue(source.Length == dest.Length, nameof(source), "Input spans must be of same length!");

#if NETCOREAPP2_1
#if SUPPORTS_EXTENDED_INTRINSICS
ExtendedIntrinsics.BulkConvertNormalizedFloatToByteClampOverflowsReduce(ref source, ref dest);
#else
BasicIntrinsics256.BulkConvertNormalizedFloatToByteClampOverflowsReduce(ref source, ref dest);
Expand Down
6 changes: 5 additions & 1 deletion src/ImageSharp/Common/Helpers/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ internal static class TestHelpers
/// Only intended to be used in tests!
/// </summary>
internal const string ImageSharpBuiltAgainst =
#if NETCOREAPP2_1
#if NET472
"netfx4.7.2";
#elif NETCOREAPP2_1
"netcoreapp2.1";
#elif NETSTANDARD1_3
"netstandard1.3";
#else
"netstandard2.0";
#endif
Expand Down
13 changes: 9 additions & 4 deletions src/ImageSharp/ImageSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix>
<VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix>
<Authors>Six Labors and contributors</Authors>
<TargetFrameworks>netstandard1.3;netstandard2.0;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>netstandard1.3;netstandard2.0;netcoreapp2.1;net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>SixLabors.ImageSharp</AssemblyName>
Expand All @@ -31,9 +31,15 @@
<Features>IOperation</Features>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' OR '$(TargetFramework)' == 'net472' ">
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Shared\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.1" />
<PackageReference Include="SixLabors.Core" Version="1.0.0-beta0006" />
Expand All @@ -43,15 +49,14 @@
</PackageReference>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.IO.UnmanagedMemoryStream" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.IO.UnmanagedMemoryStream" Version="4.3.0" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.Threading.Tasks.Parallel" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>..\..\ImageSharp.ruleset</CodeAnalysisRuleSet>
<RootNamespace>SixLabors.ImageSharp</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion tests/ImageSharp.Tests/ImageSharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;net471;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net462;net472;netcoreapp2.1</TargetFrameworks>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<DebugType Condition="$(codecov) != ''">full</DebugType>
Expand Down
2 changes: 2 additions & 0 deletions tests/ImageSharp.Tests/RunExtendedTests.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ dotnet xunit -nobuild -c Release -f net47
dotnet xunit -nobuild -c Release -f net47 -x86
dotnet xunit -nobuild -c Release -f net471
dotnet xunit -nobuild -c Release -f net471 -x86
dotnet xunit -nobuild -c Release -f net472
dotnet xunit -nobuild -c Release -f net472 -x86

0 comments on commit f52be32

Please sign in to comment.