diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index f7c79eac..fa25ac2b 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -7,15 +7,14 @@ 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
- - name: Setup .NET SDK
+ - name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- include-prerelease: true
- name: Build
run: dotnet build src\ComputeSharp\ComputeSharp.csproj -c Release
shell: cmd
@@ -24,20 +23,35 @@ jobs:
run-tests:
if: success()
needs: [build-project]
- runs-on: windows-latest
+ runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v2
- - name: Setup .NET SDK
+ - name: Setup .NET Core 3.1 SDK
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 3.1.x
+ - name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- include-prerelease: true
- - name: Run ComputeSharp.Tests
- run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -v n -l "console;verbosity=detailed"
+ - name: Run ComputeSharp.Tests (.NET 6)
+ run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed"
shell: cmd
- - name: Run ComputeSharp.Tests.Internals
- run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -v n -l "console;verbosity=detailed"
+ - name: Run ComputeSharp.Tests.Internals (.NET 6)
+ run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed"
+ shell: cmd
+ - name: Run ComputeSharp.Tests (.NET Core 3.1)
+ run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed"
+ shell: cmd
+ - 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"
@@ -47,33 +61,60 @@ jobs:
run-samples:
if: success()
needs: [run-tests]
- runs-on: windows-latest
+ runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v2
- - name: Setup .NET SDK
+ - name: Setup .NET Core 3.1 SDK
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 3.1.x
+ - name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- include-prerelease: true
- - name: Build ComputeSharp.Sample
- run: dotnet build samples\ComputeSharp.Sample\ComputeSharp.Sample.csproj -c Release
+ - name: Build ComputeSharp.Sample (.NET 6)
+ run: dotnet build samples\ComputeSharp.Sample\ComputeSharp.Sample.csproj -c Release -f net6.0
shell: cmd
- - name: Run ComputeSharp.Sample
+ - name: Run ComputeSharp.Sample (.NET 6)
run: dotnet samples\ComputeSharp.Sample\bin\Release\net6.0\ComputeSharp.Sample.dll
shell: cmd
+ - name: Build ComputeSharp.Sample (.NET Core 3.1)
+ run: dotnet build samples\ComputeSharp.Sample\ComputeSharp.Sample.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -r win-x64
+ shell: cmd
+ - 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
- name: Run ComputeSharp.Sample.FSharp
run: dotnet samples\ComputeSharp.Sample.FSharp\bin\Release\net6.0\ComputeSharp.Sample.FSharp.dll
shell: cmd
- - name: Build ComputeSharp.ImageProcessing.csproj
- run: dotnet build samples\ComputeSharp.ImageProcessing\ComputeSharp.ImageProcessing.csproj -c Release
+ - name: Build ComputeSharp.ImageProcessing.csproj (.NET 6)
+ run: dotnet build samples\ComputeSharp.ImageProcessing\ComputeSharp.ImageProcessing.csproj -c Release -f net6.0
shell: cmd
- - name: Run ComputeSharp.ImageProcessing.csproj
+ - name: Run ComputeSharp.ImageProcessing.csproj (.NET 6)
run: dotnet samples\ComputeSharp.ImageProcessing\bin\Release\net6.0\ComputeSharp.ImageProcessing.dll
shell: cmd
+ - name: Build ComputeSharp.ImageProcessing.csproj (.NET Core 3.1)
+ run: dotnet build samples\ComputeSharp.ImageProcessing\ComputeSharp.ImageProcessing.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -r win-x64
+ shell: cmd
+ - 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
@@ -84,15 +125,14 @@ 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
- - name: Setup .NET SDK
+ - name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- include-prerelease: true
- name: Build
run: dotnet build src\ComputeSharp.Package\ComputeSharp.Package.msbuildproj -c Release /p:ContinuousIntegrationBuild=True
shell: cmd
@@ -108,15 +148,14 @@ jobs:
verify-package:
if: success()
needs: [build-package]
- runs-on: windows-latest
+ runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v2
- - name: Setup .NET SDK
+ - name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- include-prerelease: true
- name: Create local NuGet feed
run: mkdir src\ComputeSharp.Package\bin\Release
shell: cmd
@@ -125,12 +164,24 @@ jobs:
with:
name: ComputeSharp.nupkg
path: src\ComputeSharp.Package\bin\Release\ComputeSharp.nupkg
- - name: Build ComputeSharp.Sample.NuGet
- run: dotnet build samples\ComputeSharp.Sample.NuGet\ComputeSharp.Sample.NuGet.csproj -c Release
+ - name: Build ComputeSharp.Sample.NuGet (.NET 6)
+ run: dotnet build samples\ComputeSharp.Sample.NuGet\ComputeSharp.Sample.NuGet.csproj -c Release -f net6.0
shell: cmd
- - name: Run ComputeSharp.Sample.NuGet
+ - name: Run ComputeSharp.Sample.NuGet (.NET 6)
run: dotnet samples\ComputeSharp.Sample.NuGet\bin\Release\net6.0\ComputeSharp.Sample.NuGet.dll
shell: cmd
+ - name: Build ComputeSharp.Sample.NuGet (.NET Core 3.1)
+ run: dotnet build samples\ComputeSharp.Sample.NuGet\ComputeSharp.Sample.NuGet.csproj -c Release -f netcoreapp3.1 -r win-x64
+ shell: cmd
+ - 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
@@ -138,15 +189,14 @@ jobs:
verify-libs:
if: success()
needs: [verify-package]
- runs-on: windows-latest
+ runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v2
- - name: Setup .NET SDK
+ - name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- include-prerelease: true
- name: Run ComputeSharp.Tests.NativeLibrariesResolver
run: dotnet test tests\ComputeSharp.Tests.NativeLibrariesResolver\ComputeSharp.Tests.NativeLibrariesResolver.csproj -v n -l "console;verbosity=detailed"
shell: cmd
\ No newline at end of file
diff --git a/ComputeSharp.sln b/ComputeSharp.sln
index c62ff249..ac5b7e06 100644
--- a/ComputeSharp.sln
+++ b/ComputeSharp.sln
@@ -48,112 +48,172 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ComputeSharp.Sample.FSharp"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Sample.FSharp.Shaders", "samples\ComputeSharp.Sample.FSharp.Shaders\ComputeSharp.Sample.FSharp.Shaders.csproj", "{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Polyfills", "Polyfills", "{8DCE343F-BA78-4FE1-B562-B57C603A8BAA}"
+EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ComputeSharp.NetStandard", "src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.shproj", "{A5997814-D8D2-4541-87AC-C3E53CAA67C0}"
+EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "TerraFX.Interop.Windows", "src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.shproj", "{514FF00E-BBF0-4D55-A47C-EEEB6208ADCE}"
+EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
+ src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5
+ src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5
+ src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{514ff00e-bbf0-4d55-a47c-eeeb6208adce}*SharedItemsImports = 13
samples\ComputeSharp.Sample.Shared\ComputeSharp.Sample.Shared.projitems*{7048deea-0a6f-46a0-b951-b682a8f1cb75}*SharedItemsImports = 5
samples\ComputeSharp.Sample.Shared\ComputeSharp.Sample.Shared.projitems*{8cefc324-ca6c-4845-9ad9-70b92bd87057}*SharedItemsImports = 13
+ src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{a5997814-d8d2-4541-87ac-c3e53caa67c0}*SharedItemsImports = 13
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+ Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
+ Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.ActiveCfg = Debug|Any CPU
- {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.Build.0 = Debug|Any CPU
- {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.Build.0 = Release|Any CPU
- {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.ActiveCfg = Release|Any CPU
- {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.Build.0 = Release|Any CPU
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.ActiveCfg = Debug|x64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.Build.0 = Debug|x64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|ARM64.Build.0 = Debug|ARM64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.ActiveCfg = Debug|x64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.Build.0 = Debug|x64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.ActiveCfg = Release|x64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.Build.0 = Release|x64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|ARM64.ActiveCfg = Release|ARM64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|ARM64.Build.0 = Release|ARM64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.ActiveCfg = Release|x64
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.Build.0 = Release|x64
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|ARM64.Build.0 = Debug|Any CPU
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|x64.ActiveCfg = Debug|Any CPU
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|x64.Build.0 = Debug|Any CPU
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|ARM64.Build.0 = Release|Any CPU
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|x64.ActiveCfg = Release|Any CPU
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|x64.Build.0 = Release|Any CPU
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|ARM64.Build.0 = Debug|Any CPU
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|x64.ActiveCfg = Debug|Any CPU
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|x64.Build.0 = Debug|Any CPU
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|Any CPU.ActiveCfg = Release|Any CPU
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|Any CPU.Build.0 = Release|Any CPU
+ {524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|ARM64.Build.0 = Release|Any CPU
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|x64.ActiveCfg = Release|Any CPU
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|x64.Build.0 = Release|Any CPU
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|Any CPU.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|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|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|x64.ActiveCfg = Release|Any CPU
- {E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|x64.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|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|x64.ActiveCfg = Debug|Any CPU
- {E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|x64.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|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|x64.ActiveCfg = Release|Any CPU
- {E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|x64.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|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
+ {EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|ARM64.Build.0 = Debug|Any CPU
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|x64.ActiveCfg = Debug|Any CPU
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|x64.Build.0 = Debug|Any CPU
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|ARM64.Build.0 = Release|Any CPU
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|x64.ActiveCfg = Release|Any CPU
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|x64.Build.0 = Release|Any CPU
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|ARM64.Build.0 = Debug|Any CPU
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|x64.ActiveCfg = Debug|Any CPU
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|x64.Build.0 = Debug|Any CPU
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|ARM64.Build.0 = Release|Any CPU
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|x64.ActiveCfg = Release|Any CPU
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|x64.Build.0 = Release|Any CPU
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|ARM64.Build.0 = Debug|Any CPU
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|x64.ActiveCfg = Debug|Any CPU
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|x64.Build.0 = Debug|Any CPU
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|ARM64.Build.0 = Release|Any CPU
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|x64.ActiveCfg = Release|Any CPU
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|x64.Build.0 = Release|Any CPU
{BF52326F-E415-49E6-8595-62762216762B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF52326F-E415-49E6-8595-62762216762B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BF52326F-E415-49E6-8595-62762216762B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {BF52326F-E415-49E6-8595-62762216762B}.Debug|ARM64.Build.0 = Debug|Any CPU
{BF52326F-E415-49E6-8595-62762216762B}.Debug|x64.ActiveCfg = Debug|Any CPU
{BF52326F-E415-49E6-8595-62762216762B}.Debug|x64.Build.0 = Debug|Any CPU
{BF52326F-E415-49E6-8595-62762216762B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF52326F-E415-49E6-8595-62762216762B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BF52326F-E415-49E6-8595-62762216762B}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {BF52326F-E415-49E6-8595-62762216762B}.Release|ARM64.Build.0 = Release|Any CPU
{BF52326F-E415-49E6-8595-62762216762B}.Release|x64.ActiveCfg = Release|Any CPU
{BF52326F-E415-49E6-8595-62762216762B}.Release|x64.Build.0 = Release|Any CPU
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Debug|ARM64.Build.0 = Debug|Any CPU
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Debug|x64.ActiveCfg = Debug|Any CPU
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Debug|x64.Build.0 = Debug|Any CPU
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Release|ARM64.Build.0 = Release|Any CPU
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Release|x64.ActiveCfg = Release|Any CPU
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Release|x64.Build.0 = Release|Any CPU
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|ARM64.Build.0 = Debug|Any CPU
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|x64.ActiveCfg = Debug|Any CPU
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|x64.Build.0 = Debug|Any CPU
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7C625EC4-F599-4350-A915-F046DF2406D3}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {7C625EC4-F599-4350-A915-F046DF2406D3}.Release|ARM64.Build.0 = Release|Any CPU
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|x64.ActiveCfg = Release|Any CPU
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|x64.Build.0 = Release|Any CPU
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|ARM64.Build.0 = Debug|Any CPU
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|x64.ActiveCfg = Debug|Any CPU
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|x64.Build.0 = Debug|Any CPU
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|ARM64.Build.0 = Release|Any CPU
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|x64.ActiveCfg = Release|Any CPU
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
@@ -172,6 +232,8 @@ Global
{E7C9247D-016B-4819-AF9F-0E9B3591E04B} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1}
{7C625EC4-F599-4350-A915-F046DF2406D3} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1}
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1}
+ {A5997814-D8D2-4541-87AC-C3E53CAA67C0} = {8DCE343F-BA78-4FE1-B562-B57C603A8BAA}
+ {514FF00E-BBF0-4D55-A47C-EEEB6208ADCE} = {8DCE343F-BA78-4FE1-B562-B57C603A8BAA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4664C5E3-0340-4E22-BCFD-98AAEDF5F2DC}
diff --git a/Directory.Build.props b/Directory.Build.props
index 7169705b..19eaa132 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,5 +6,6 @@
true
Sergio Pedri
Copyright (c) 2021 Sergio Pedri
+ $(NoWarn);MSB3270
\ No newline at end of file
diff --git a/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj b/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj
index fa78d65d..e9acb27c 100644
--- a/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj
+++ b/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj
@@ -2,7 +2,8 @@
Exe
- net6.0
+ net472;netcoreapp3.1;net6.0
+ AnyCPU;x64;ARM64
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
index 7572930d..e41bb4f6 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
@@ -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++)
{
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
index 5176edea..5fb59656 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
@@ -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;
}
diff --git a/samples/ComputeSharp.ImageProcessing/Program.cs b/samples/ComputeSharp.ImageProcessing/Program.cs
index 2487916f..0318a63e 100644
--- a/samples/ComputeSharp.ImageProcessing/Program.cs
+++ b/samples/ComputeSharp.ImageProcessing/Program.cs
@@ -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);
}
}
diff --git a/samples/ComputeSharp.Sample.NuGet/ComputeSharp.Sample.NuGet.csproj b/samples/ComputeSharp.Sample.NuGet/ComputeSharp.Sample.NuGet.csproj
index 8a48f676..a518813b 100644
--- a/samples/ComputeSharp.Sample.NuGet/ComputeSharp.Sample.NuGet.csproj
+++ b/samples/ComputeSharp.Sample.NuGet/ComputeSharp.Sample.NuGet.csproj
@@ -2,7 +2,8 @@
Exe
- net6.0
+ net472;netcoreapp3.1;net6.0
+ AnyCPU;x64;ARM64
diff --git a/samples/ComputeSharp.Sample.Shared/Program.cs b/samples/ComputeSharp.Sample.Shared/Program.cs
index 3fc4ead9..c1dfd234 100644
--- a/samples/ComputeSharp.Sample.Shared/Program.cs
+++ b/samples/ComputeSharp.Sample.Shared/Program.cs
@@ -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);
diff --git a/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj b/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj
index 54c7d518..ce698002 100644
--- a/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj
+++ b/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj
@@ -2,7 +2,8 @@
Exe
- net6.0
+ net472;netcoreapp3.1;net6.0
+ AnyCPU;x64;ARM64
diff --git a/src/ComputeSharp.NetStandard/ComputeSharp.NetStandard.projitems b/src/ComputeSharp.NetStandard/ComputeSharp.NetStandard.projitems
new file mode 100644
index 00000000..ad0b58c0
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/ComputeSharp.NetStandard.projitems
@@ -0,0 +1,27 @@
+
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+ true
+ a5997814-d8d2-4541-87ac-c3e53caa67c0
+
+
+ ComputeSharp.NetStandard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/ComputeSharp.NetStandard.shproj b/src/ComputeSharp.NetStandard/ComputeSharp.NetStandard.shproj
new file mode 100644
index 00000000..1ab4d44d
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/ComputeSharp.NetStandard.shproj
@@ -0,0 +1,13 @@
+
+
+
+ a5997814-d8d2-4541-87ac-c3e53caa67c0
+ 14.0
+
+
+
+
+
+
+
+
diff --git a/src/ComputeSharp.NetStandard/System/Collections.Generic/DictionaryExtensions.cs b/src/ComputeSharp.NetStandard/System/Collections.Generic/DictionaryExtensions.cs
new file mode 100644
index 00000000..3c8199dc
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/Collections.Generic/DictionaryExtensions.cs
@@ -0,0 +1,29 @@
+namespace System.Collections.Generic;
+
+///
+/// A helper type with extensions for the type.
+///
+internal static class DictionaryExtensions
+{
+ ///
+ /// Tries to remove an item from a instance and returns it if present.
+ ///
+ /// The type of dictionary keys.
+ /// The type of dictionary values.
+ /// The input instance.
+ /// The lookup key to use.
+ /// The resulting item, if present.
+ /// Whether or not an item was found with the given key.
+ public static bool Remove(this Dictionary dictionary, TKey key, out TValue? value)
+ where TKey : notnull
+ {
+ if (dictionary.TryGetValue(key, out value))
+ {
+ _ = dictionary.Remove(key);
+
+ return true;
+ }
+
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/Collections.Generic/QueueExtensions.cs b/src/ComputeSharp.NetStandard/System/Collections.Generic/QueueExtensions.cs
new file mode 100644
index 00000000..8ca46f02
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/Collections.Generic/QueueExtensions.cs
@@ -0,0 +1,28 @@
+namespace System.Collections.Generic;
+
+///
+/// A helper type with extensions for the type.
+///
+internal static class QueueExtensions
+{
+ ///
+ /// Tries to dequeue an item from the input instance.
+ ///
+ /// The type of items in the queue.
+ /// The input queue.
+ /// The resulting item, if any.
+ /// Whether or not an item was found.
+ public static bool TryDequeue(this Queue queue, out T? result)
+ {
+ if (queue.Count > 0)
+ {
+ result = queue.Dequeue();
+
+ return true;
+ }
+
+ result = default!;
+
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/Enum.cs b/src/ComputeSharp.NetStandard/System/Enum.cs
new file mode 100644
index 00000000..6a601cc1
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/Enum.cs
@@ -0,0 +1,19 @@
+namespace ComputeSharp.NetStandard.System;
+
+///
+/// A polyfill type that mirrors some methods from on .NET 6.
+///
+internal static class Enum
+{
+ ///
+ /// Returns the name of the input enum value.
+ ///
+ /// Specifies the type of the enum element.
+ /// The input enum value.
+ /// The name of .
+ public static string GetName(T value)
+ where T : unmanaged, global::System.Enum
+ {
+ return global::System.Enum.GetName(typeof(T), value)!;
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/FormatExtensions.cs b/src/ComputeSharp.NetStandard/System/FormatExtensions.cs
new file mode 100644
index 00000000..ad799798
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/FormatExtensions.cs
@@ -0,0 +1,23 @@
+using System.Runtime.CompilerServices;
+
+namespace System;
+
+///
+/// A polyfill type with additional formatting extensions.
+///
+internal static class FormatExtensions
+{
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static string ToString(this T value, string? format)
+ {
+ throw new NotSupportedException("This API is not supported on this target.");
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static string ToString(this T value, string? format, IFormatProvider? formatProvider)
+ {
+ throw new NotSupportedException("This API is not supported on this target.");
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/GC.cs b/src/ComputeSharp.NetStandard/System/GC.cs
new file mode 100644
index 00000000..cd9c26ac
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/GC.cs
@@ -0,0 +1,21 @@
+namespace ComputeSharp.NetStandard.System;
+
+///
+/// A polyfill type that mirrors some methods from on .NET 6.
+///
+internal static class GC
+{
+ ///
+ /// Allocate an array while skipping zero-initialization if possible.
+ ///
+ /// Specifies the type of the array element.
+ /// Specifies the length of the array.
+ /// Specifies whether the allocated array must be pinned.
+ ///
+ /// If pinned is set to true, must not be a reference type or a type that contains object references.
+ ///
+ public static T[] AllocateUninitializedArray(int length, bool pinned = false)
+ {
+ return new T[length];
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/IntPtrExtensions.cs b/src/ComputeSharp.NetStandard/System/IntPtrExtensions.cs
new file mode 100644
index 00000000..465f1ede
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/IntPtrExtensions.cs
@@ -0,0 +1,23 @@
+using System.Runtime.CompilerServices;
+
+namespace System;
+
+///
+/// A polyfill type with extensions for and .
+///
+internal static class IntPtrExtensions
+{
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static int CompareTo(this nint left, nint right)
+ {
+ return left.CompareTo(right);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static int CompareTo(this nuint left, nuint right)
+ {
+ return left.CompareTo(right);
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/Path.cs b/src/ComputeSharp.NetStandard/System/Path.cs
new file mode 100644
index 00000000..654ded4d
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/Path.cs
@@ -0,0 +1,20 @@
+using System;
+
+namespace ComputeSharp.NetStandard.System.IO;
+
+///
+/// A polyfill type that mirrors some methods from on .NET 6.
+///
+internal static class Path
+{
+ ///
+ /// Returns the extension of the given path.
+ ///
+ ///
+ /// The returned value is an empty if the given path does not include an extension.
+ ///
+ public static ReadOnlySpan GetExtension(ReadOnlySpan path)
+ {
+ return global::System.IO.Path.GetExtension(path.ToString()).AsSpan();
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/InterpolatedStringHandlerArgumentAttribute.cs b/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/InterpolatedStringHandlerArgumentAttribute.cs
new file mode 100644
index 00000000..7fe883be
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/InterpolatedStringHandlerArgumentAttribute.cs
@@ -0,0 +1,28 @@
+namespace System.Runtime.CompilerServices;
+
+///
+/// Indicates which arguments to a method involving an interpolated string handler should be passed to that handler.
+///
+[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
+public sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The name of the argument that should be passed to the handler.
+ /// may be used as the name of the receiver in an instance method.
+ public InterpolatedStringHandlerArgumentAttribute(string argument) => Arguments = new string[] { argument };
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The names of the arguments that should be passed to the handler.
+ /// may be used as the name of the receiver in an instance method.
+ public InterpolatedStringHandlerArgumentAttribute(params string[] arguments) => Arguments = arguments;
+
+ ///
+ /// Gets the names of the arguments that should be passed to the handler.
+ ///
+ /// may be used as the name of the receiver in an instance method.
+ public string[] Arguments { get; }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/InterpolatedStringHandlerAttribute.cs b/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/InterpolatedStringHandlerAttribute.cs
new file mode 100644
index 00000000..75904a51
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/InterpolatedStringHandlerAttribute.cs
@@ -0,0 +1,9 @@
+namespace System.Runtime.CompilerServices;
+
+///
+/// Indicates the attributed type is to be used as an interpolated string handler.
+///
+[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
+public sealed class InterpolatedStringHandlerAttribute : Attribute
+{
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.SourceGenerators/Helpers/RuntimeHelpers.cs b/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/RuntimeHelpers.cs
similarity index 66%
rename from src/ComputeSharp.SourceGenerators/Helpers/RuntimeHelpers.cs
rename to src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/RuntimeHelpers.cs
index 55cafd42..552f2b33 100644
--- a/src/ComputeSharp.SourceGenerators/Helpers/RuntimeHelpers.cs
+++ b/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/RuntimeHelpers.cs
@@ -1,9 +1,10 @@
using System;
+using System.Runtime.InteropServices;
-namespace ComputeSharp.SourceGenerators.Helpers;
+namespace ComputeSharp.NetStandard.System.Runtime.CompilerServices;
///
-/// A polyfill type that mirrors some methods from on .NET 5.
+/// A polyfill type that mirrors some methods from on .NET 5.
///
internal static class RuntimeHelpers
{
@@ -13,5 +14,5 @@ internal static class RuntimeHelpers
/// The type to associate the memory to.
/// The size in byte of the memory to allocate.
/// A pointer to the allocated memory.
- public static IntPtr AllocateTypeAssociatedMemory(Type type, int size) => default;
-}
+ public static IntPtr AllocateTypeAssociatedMemory(Type type, int size) => Marshal.AllocHGlobal(size);
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs b/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs
new file mode 100644
index 00000000..1339a5ae
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/Runtime/CompilerServices/SkipLocalsInitAttribute.cs
@@ -0,0 +1,27 @@
+namespace System.Runtime.CompilerServices;
+
+///
+/// Used to indicate to the compiler that the .locals init
+/// flag should not be set in method headers.
+///
+///
+/// This attribute is unsafe because it may reveal uninitialized memory to
+/// the application in certain instances (e.g., reading from uninitialized
+/// stackalloc'd memory). If applied to a method directly, the attribute
+/// applies to that method and all nested functions (lambdas, local
+/// functions) below it. If applied to a type or module, it applies to all
+/// methods nested inside. This attribute is intentionally not permitted on
+/// assemblies. Use at the module level instead to apply to multiple type
+/// declarations.
+///
+[AttributeUsage(AttributeTargets.Module
+ | AttributeTargets.Class
+ | AttributeTargets.Struct
+ | AttributeTargets.Interface
+ | AttributeTargets.Constructor
+ | AttributeTargets.Method
+ | AttributeTargets.Property
+ | AttributeTargets.Event, Inherited = false)]
+internal sealed class SkipLocalsInitAttribute : Attribute
+{
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/Runtime/InteropServices/MemoryMarshal.cs b/src/ComputeSharp.NetStandard/System/Runtime/InteropServices/MemoryMarshal.cs
new file mode 100644
index 00000000..0c781495
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/Runtime/InteropServices/MemoryMarshal.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Runtime.CompilerServices;
+
+namespace ComputeSharp.NetStandard.System.Runtime.InteropServices;
+
+///
+/// A polyfill type that mirrors some methods from on .NET 6.
+///
+internal static class MemoryMarshal
+{
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static ref T GetReference(Span span)
+ {
+ return ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(span);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static ref T GetReference(ReadOnlySpan span)
+ {
+ return ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(span);
+ }
+
+ ///
+ /// Returns a reference to the 0th element of . If the array is empty, returns a reference
+ /// to where the 0th element would have been stored. Such a reference may be used for pinning but must never be dereferenced.
+ ///
+ /// is .
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static ref T GetArrayDataReference(T[] array)
+ {
+ return ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(array.AsSpan());
+ }
+
+ ///
+ /// Creates a new from a given reference.
+ ///
+ /// The type of reference to wrap.
+ /// The target reference.
+ /// The length of the to create.
+ /// A new wrapping .
+ public static unsafe Span CreateSpan(ref T value, int length)
+ {
+ return new(Unsafe.AsPointer(ref value), length);
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/Runtime/Versioning/OSPlatformAttribute.cs b/src/ComputeSharp.NetStandard/System/Runtime/Versioning/OSPlatformAttribute.cs
new file mode 100644
index 00000000..2cf0bc16
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/Runtime/Versioning/OSPlatformAttribute.cs
@@ -0,0 +1,15 @@
+namespace System.Runtime.Versioning;
+
+///
+/// Base type for all platform-specific API attributes.
+///
+
+internal abstract class OSPlatformAttribute : Attribute
+{
+ private protected OSPlatformAttribute(string platformName)
+ {
+ PlatformName = platformName;
+ }
+
+ public string PlatformName { get; }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.NetStandard/System/Runtime/Versioning/SupportedOSVersionAttribute.cs b/src/ComputeSharp.NetStandard/System/Runtime/Versioning/SupportedOSVersionAttribute.cs
new file mode 100644
index 00000000..372c58f0
--- /dev/null
+++ b/src/ComputeSharp.NetStandard/System/Runtime/Versioning/SupportedOSVersionAttribute.cs
@@ -0,0 +1,32 @@
+namespace System.Runtime.Versioning;
+
+///
+/// Records the operating system (and minimum version) that supports an API. Multiple
+/// attributes can be applied to indicate support on multiple operating systems.
+///
+///
+/// Callers can apply a
+/// or use guards to prevent calls to APIs on unsupported operating systems.
+/// A given platform should only be specified once.
+///
+[AttributeUsage(AttributeTargets.Assembly |
+ AttributeTargets.Class |
+ AttributeTargets.Constructor |
+ AttributeTargets.Enum |
+ AttributeTargets.Event |
+ AttributeTargets.Field |
+ AttributeTargets.Interface |
+ AttributeTargets.Method |
+ AttributeTargets.Module |
+ AttributeTargets.Property |
+ AttributeTargets.Struct,
+ AllowMultiple = true,
+ Inherited = false)]
+
+internal sealed class SupportedOSPlatformAttribute : OSPlatformAttribute
+{
+ public SupportedOSPlatformAttribute(string platformName)
+ : base(platformName)
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj
index 12a81b4f..59ea54ce 100644
--- a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj
+++ b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj
@@ -14,6 +14,8 @@
manually linking the source files from ComputeSharp\Core in here. We only need them to extract metadata
and to match members based on full name, so the types being in the generator assembly are not an issue.-->
+
+
diff --git a/src/ComputeSharp.SourceGenerators/Helpers/MemoryMarshal.cs b/src/ComputeSharp.SourceGenerators/Helpers/MemoryMarshal.cs
deleted file mode 100644
index 7ae4730f..00000000
--- a/src/ComputeSharp.SourceGenerators/Helpers/MemoryMarshal.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-
-namespace ComputeSharp.SourceGenerators.Helpers;
-
-///
-/// A polyfill type that mirrors some methods from on .NET 5.
-///
-internal static class MemoryMarshal
-{
- ///
- public static ref T GetReference(Span span)
- {
- return ref System.Runtime.InteropServices.MemoryMarshal.GetReference(span);
- }
-
- ///
- /// Creates a new from a given reference.
- ///
- /// The type of reference to wrap.
- /// The target reference.
- /// The length of the to create.
- /// A new wrapping .
- public static Span CreateSpan(ref T value, int length) => default;
-}
diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs
index 29b01464..986e19ca 100644
--- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs
+++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.cs
@@ -89,8 +89,9 @@ public sealed partial class IShaderGenerator : ISourceGenerator
Literal("This method is not intended to be used directly by user code"))))))
};
- // Add [SkipLocalsInit] if the target project allows it
- if (context.Compilation.Options is CSharpCompilationOptions { AllowUnsafe: true })
+ // Add [SkipLocalsInit] if the target project allows it and can access it
+ if (context.Compilation.Options is CSharpCompilationOptions { AllowUnsafe: true } &&
+ context.Compilation.GetTypeByMetadataName("System.Runtime.CompilerServices.SkipLocalsInit") is not null)
{
attributes.Add(AttributeList(SingletonSeparatedList(Attribute(IdentifierName("global::System.Runtime.CompilerServices.SkipLocalsInit")))));
}
diff --git a/src/ComputeSharp/ComputeSharp.csproj b/src/ComputeSharp/ComputeSharp.csproj
index d077610d..3010bfeb 100644
--- a/src/ComputeSharp/ComputeSharp.csproj
+++ b/src/ComputeSharp/ComputeSharp.csproj
@@ -1,17 +1,43 @@
- net6.0
+ netstandard2.0;net6.0
bin\Release
ComputeSharp.xml
ComputeSharp
+ AnyCPU;x64;ARM64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(NoWarn);CS1591
+
+
+
+
+
+
+
+ $(NoWarn);CS0649
+
+
diff --git a/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs b/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs
index bd2c2c39..0491aa04 100644
--- a/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs
+++ b/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs
@@ -174,9 +174,9 @@ public static class GraphicsDeviceExtensions
///
/// Allocates a new instance of the specified type.
///
- /// The type of items in the buffer.
- /// The target instance to allocate the buffer for.
- /// The type of buffer to allocate.
+ /// The type of items in the texture.
+ /// The target instance to allocate the texture for.
+ /// The type of texture to allocate.
/// The width of the texture to create.
/// The height of the texture to create.
/// The depth of the texture to create.
@@ -220,7 +220,7 @@ public static class GraphicsDeviceExtensions
///
/// The type of items in the texture.
/// The target instance to allocate the texture for.
- /// The type of buffer to allocate.
+ /// The type of texture to allocate.
/// The data to load on the texture.
/// The width of the texture to create.
/// The height of the texture to create.
@@ -242,7 +242,7 @@ public static class GraphicsDeviceExtensions
///
/// The type of items in the texture.
/// The target instance to allocate the texture for.
- /// The type of buffer to allocate.
+ /// The type of texture to allocate.
/// The data to load on the texture.
/// The width of the texture to create.
/// The height of the texture to create.
@@ -299,4 +299,105 @@ public static class GraphicsDeviceExtensions
_ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
};
}
+
+ ///
+ /// Loads a new readonly 2D texture with the contents of the specified file.
+ ///
+ /// The type of items to store in the texture.
+ /// The type of pixels used on the GPU side.
+ /// The instance to use to allocate the texture.
+ /// The type of texture to allocate.
+ /// The type of filepath to use.
+ /// The filename of the image file to load and decode into the texture.
+ /// A instance with the contents of the specified file.
+ [Pure]
+ public static Texture2D LoadTexture2D(this GraphicsDevice device, Type textureType, Type inputType, string filename)
+ where T : unmanaged, IUnorm
+ where TPixel : unmanaged
+ {
+ return textureType switch
+ {
+ _ when textureType == typeof(ReadOnlyTexture2D<,>) => inputType switch
+ {
+ _ when inputType == typeof(string) => device.LoadReadOnlyTexture2D(filename),
+ _ when inputType == typeof(ReadOnlySpan) => device.LoadReadOnlyTexture2D(filename.AsSpan()),
+ _ => throw new ArgumentException($"Invalid input type: {inputType}", nameof(inputType))
+ },
+ _ when textureType == typeof(ReadWriteTexture2D<,>) => inputType switch
+ {
+ _ when inputType == typeof(string) => device.LoadReadWriteTexture2D(filename),
+ _ when inputType == typeof(ReadOnlySpan) => device.LoadReadWriteTexture2D(filename.AsSpan()),
+ _ => throw new ArgumentException($"Invalid input type: {inputType}", nameof(inputType))
+ },
+ _ => throw new ArgumentException($"Invalid texture type: {textureType}", nameof(textureType))
+ };
+ }
+
+ ///
+ /// Loads a new readonly 2D texture with the contents of the specified file.
+ ///
+ /// The type of items to store in the texture.
+ /// The type of pixels used on the GPU side.
+ /// The instance to use to allocate the texture.
+ /// The type of texture to allocate.
+ /// The buffer with the image data to load and decode into the texture.
+ /// A instance with the contents of the specified file.
+ [Pure]
+ public static Texture2D LoadTexture2D(this GraphicsDevice device, Type type, byte[] buffer)
+ where T : unmanaged, IUnorm
+ where TPixel : unmanaged
+ {
+ return type switch
+ {
+ _ when type == typeof(ReadOnlyTexture2D<,>) => device.LoadReadOnlyTexture2D(buffer),
+ _ when type == typeof(ReadWriteTexture2D<,>) => device.LoadReadWriteTexture2D(buffer),
+ _ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
+ };
+ }
+
+ ///
+ /// Saves a texture to a specified file.
+ ///
+ /// The type of items to store in the texture.
+ /// The texture to save to an image.
+ /// The type of filepath to use.
+ /// The filename of the image file to save.
+ public static void Save(this Texture2D texture, Type inputType, string filename)
+ where T : unmanaged
+ {
+ switch (inputType)
+ {
+ case var _ when inputType == typeof(string):
+ texture.Save(filename);
+ break;
+ case var _ when inputType == typeof(ReadOnlySpan):
+ texture.Save(filename.AsSpan());
+ break;
+ default:
+ throw new ArgumentException($"Invalid input type: {inputType}", nameof(inputType));
+ }
+ }
+
+ ///
+ /// Saves a texture to a specified file.
+ ///
+ /// The type of items to store in the texture.
+ /// The texture to save to an image.
+ /// The type of filepath to use.
+ /// The filename of the image file to save.
+ public static void Save(this ReadBackTexture2D texture, Type inputType, string filename)
+ where T : unmanaged
+ {
+ switch (inputType)
+ {
+ case var _ when inputType == typeof(string):
+ texture.Save(filename);
+ break;
+ case var _ when inputType == typeof(ReadOnlySpan):
+ texture.Save(filename.AsSpan());
+ break;
+ default:
+ throw new ArgumentException($"Invalid input type: {inputType}", nameof(inputType));
+ }
+ }
}
diff --git a/tests/ComputeSharp.Tests/ImagingTests.cs b/tests/ComputeSharp.Tests/ImagingTests.cs
index 54b2cef1..dc42f0a7 100644
--- a/tests/ComputeSharp.Tests/ImagingTests.cs
+++ b/tests/ComputeSharp.Tests/ImagingTests.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
+using ComputeSharp.Resources;
using ComputeSharp.Tests.Attributes;
using ComputeSharp.Tests.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -22,11 +23,15 @@ public class ImagingTests
{
[CombinatorialTestMethod]
[AllDevices]
- public void LoadAsRgba32FromFile(Device device)
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [Data(typeof(string))]
+ [Data(typeof(ReadOnlySpan))]
+ public void LoadAsRgba32FromFile(Device device, Type textureType, Type inputType)
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging", "city.jpg");
- using ReadOnlyTexture2D texture = device.Get().LoadReadOnlyTexture2D(path);
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, inputType, path);
using Image loaded = texture.ToImage();
using Image original = Image.Load(path);
@@ -36,11 +41,15 @@ public class ImagingTests
[CombinatorialTestMethod]
[AllDevices]
- public void LoadAsBgra32FromFile(Device device)
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [Data(typeof(string))]
+ [Data(typeof(ReadOnlySpan))]
+ public void LoadAsBgra32FromFile(Device device, Type textureType, Type inputType)
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging", "city.jpg");
- using ReadOnlyTexture2D texture = device.Get().LoadReadOnlyTexture2D(path);
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, inputType, path);
using Image loaded = texture.ToImage();
using Image original = Image.Load(path);
@@ -50,11 +59,15 @@ public class ImagingTests
[CombinatorialTestMethod]
[AllDevices]
- public void LoadAsBgra32FromFileWithSameFormat(Device device)
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [Data(typeof(string))]
+ [Data(typeof(ReadOnlySpan))]
+ public void LoadAsBgra32FromFileWithSameFormat(Device device, Type textureType, Type inputType)
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Assets", "CityAfter1024x1024Sampling.png");
- using ReadOnlyTexture2D texture = device.Get().LoadReadOnlyTexture2D(path);
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, inputType, path);
using Image loaded = texture.ToImage();
using Image original = Image.Load(path);
@@ -64,11 +77,15 @@ public class ImagingTests
[CombinatorialTestMethod]
[AllDevices]
- public void LoadAsR8FromFile(Device device)
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [Data(typeof(string))]
+ [Data(typeof(ReadOnlySpan))]
+ public void LoadAsR8FromFile(Device device, Type textureType, Type inputType)
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging", "city.jpg");
- using ReadOnlyTexture2D texture = device.Get().LoadReadOnlyTexture2D(path);
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, inputType, path);
using Image loaded = texture.ToImage();
using Image original = Image.Load(path);
@@ -78,13 +95,15 @@ public class ImagingTests
[CombinatorialTestMethod]
[AllDevices]
- public void LoadAsRgba32FromBuffer(Device device)
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ public void LoadAsRgba32FromBuffer(Device device, Type textureType)
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging", "city.jpg");
byte[] buffer = File.ReadAllBytes(path);
- using ReadOnlyTexture2D texture = device.Get().LoadReadOnlyTexture2D(buffer);
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, buffer);
using Image loaded = texture.ToImage();
using Image original = Image.Load(path);
@@ -92,48 +111,109 @@ public class ImagingTests
TolerantImageComparer.AssertEqual(original, loaded, 0.0000032f);
}
+ [CombinatorialTestMethod]
+ [Device(Device.Warp)]
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void LoadAsRgba32_WithNullPath(Device device, Type textureType)
+ {
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, typeof(string), null!);
+ }
+
[CombinatorialTestMethod]
[AllDevices]
- public void SaveRgba32AsJpeg(Device device)
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [Data(typeof(string))]
+ [Data(typeof(ReadOnlySpan))]
+ public void SaveRgba32AsJpeg(Device device, Type textureType, Type inputType)
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging");
string expectedPath = Path.Combine(path, "city.jpg");
string actualPath = Path.Combine(path, "city_rgba32_saved.jpg");
- using ReadOnlyTexture2D texture = device.Get().LoadReadOnlyTexture2D(expectedPath);
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, inputType, expectedPath);
- texture.Save(actualPath);
+ texture.Save(inputType, actualPath);
TolerantImageComparer.AssertEqual(expectedPath, actualPath, 0.00001023f);
}
[CombinatorialTestMethod]
[AllDevices]
- public void SaveBgra32AsJpeg(Device device)
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [Data(typeof(string))]
+ [Data(typeof(ReadOnlySpan))]
+ public void SaveRgba32AsJpeg_WithReadBackTexture(Device device, Type textureType, Type inputType)
+ {
+ string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging");
+ string expectedPath = Path.Combine(path, "city.jpg");
+ string actualPath = Path.Combine(path, "city_rgba32_saved.jpg");
+
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, inputType, expectedPath);
+ using ReadBackTexture2D readback = device.Get().AllocateReadBackTexture2D(texture.Width, texture.Height);
+
+ texture.CopyTo(readback);
+
+ readback.Save(inputType, actualPath);
+
+ TolerantImageComparer.AssertEqual(expectedPath, actualPath, 0.00001023f);
+ }
+
+ [CombinatorialTestMethod]
+ [Device(Device.Warp)]
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void SaveRgba32AsJpeg_WithReadBackTexture_WithNullPath(Device device, Type textureType)
+ {
+ string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging", "city.jpg");
+
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, typeof(string), path);
+ using ReadBackTexture2D readback = device.Get().AllocateReadBackTexture2D(texture.Width, texture.Height);
+
+ texture.CopyTo(readback);
+
+ readback.Save(typeof(string), null!);
+ }
+
+ [CombinatorialTestMethod]
+ [AllDevices]
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [Data(typeof(string))]
+ [Data(typeof(ReadOnlySpan))]
+ public void SaveBgra32AsJpeg(Device device, Type textureType, Type inputType)
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging");
string expectedPath = Path.Combine(path, "city.jpg");
string actualPath = Path.Combine(path, "city_bgra32_saved.jpg");
- using ReadOnlyTexture2D texture = device.Get().LoadReadOnlyTexture2D(expectedPath);
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, inputType, expectedPath);
- texture.Save(actualPath);
+ texture.Save(inputType, actualPath);
TolerantImageComparer.AssertEqual(expectedPath, actualPath, 0.00001023f);
}
[CombinatorialTestMethod]
[AllDevices]
- public void SaveR8AsJpeg(Device device)
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [Data(typeof(string))]
+ [Data(typeof(ReadOnlySpan))]
+ public void SaveR8AsJpeg(Device device, Type textureType, Type inputType)
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging");
string sourcePath = Path.Combine(path, "city.jpg");
string expectedPath = Path.Combine(path, "city_r8_reference.jpg");
string actualPath = Path.Combine(path, "city_r8_saved.jpg");
- using ReadOnlyTexture2D texture = device.Get().LoadReadOnlyTexture2D(sourcePath);
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, inputType, sourcePath);
- texture.Save(actualPath);
+ texture.Save(inputType, actualPath);
using Image original = Image.Load(sourcePath);
@@ -142,6 +222,20 @@ public class ImagingTests
TolerantImageComparer.AssertEqual(expectedPath, actualPath, 0.00004037f);
}
+ [CombinatorialTestMethod]
+ [Device(Device.Warp)]
+ [Resource(typeof(ReadOnlyTexture2D<,>))]
+ [Resource(typeof(ReadWriteTexture2D<,>))]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void SaveRgba32AsJpeg_WithNullPath(Device device, Type textureType)
+ {
+ string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging", "city.jpg");
+
+ using Texture2D texture = device.Get().LoadTexture2D(textureType, typeof(string), path);
+
+ texture.Save(typeof(string), null!);
+ }
+
///
/// An tolerant image comparer type, from ImageSharp.
///
diff --git a/tests/ComputeSharp.Tests/Polyfills/RandomExtensions.cs b/tests/ComputeSharp.Tests/Polyfills/RandomExtensions.cs
new file mode 100644
index 00000000..308c6724
--- /dev/null
+++ b/tests/ComputeSharp.Tests/Polyfills/RandomExtensions.cs
@@ -0,0 +1,25 @@
+#if !NETCOREAPP3_1_OR_GREATER
+
+namespace System;
+
+///
+/// A type with some helper methods for the class.
+///
+internal static class RandomExtensions
+{
+ ///
+ /// Fills the elements of a specified span of bytes with random numbers.
+ ///
+ /// The target random instance.
+ /// The array to be filled with random numbers.
+ public static void NextBytes(this Random random, Span buffer)
+ {
+ byte[] array = new byte[buffer.Length];
+
+ random.NextBytes(array);
+
+ array.AsSpan().CopyTo(buffer);
+ }
+}
+
+#endif
diff --git a/tests/ComputeSharp.Tests/ShadersTests.cs b/tests/ComputeSharp.Tests/ShadersTests.cs
index dfebe543..573ab028 100644
--- a/tests/ComputeSharp.Tests/ShadersTests.cs
+++ b/tests/ComputeSharp.Tests/ShadersTests.cs
@@ -152,7 +152,7 @@ public class ShadersTests
using (ReadWriteTexture2D texture = device.Get().AllocateReadWriteTexture2D(imageInfo.Width, imageInfo.Height))
{
- if (shaderType.IsAssignableTo(typeof(IComputeShader)))
+ if (typeof(IComputeShader).IsAssignableFrom(shaderType))
{
static void RunComputeShader(ReadWriteTexture2D texture)
where T : struct, IComputeShader
@@ -219,7 +219,7 @@ public class ShadersTests
using (ReadWriteTexture2D texture = device.Get().AllocateReadWriteTexture2D(imageInfo.Width, imageInfo.Height))
{
- if (shaderType.IsAssignableTo(typeof(IComputeShader)))
+ if (typeof(IComputeShader).IsAssignableFrom(shaderType))
{
Assert.AreEqual(typeof(TCompute), shaderType);
diff --git a/tests/ComputeSharp.Tests/Texture3DTests.cs b/tests/ComputeSharp.Tests/Texture3DTests.cs
index 2797a423..b360e3c8 100644
--- a/tests/ComputeSharp.Tests/Texture3DTests.cs
+++ b/tests/ComputeSharp.Tests/Texture3DTests.cs
@@ -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(p, array.Length).Enumerate())
+ {
+ item.Value = item.Index;
+ }
}
using Texture3D 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(p, result.Length), x, y, z, width, height, depth);
+ }
for (int k = 0; k < depth; k++)
{
diff --git a/tests/ComputeSharp.Tests/TransferTexture2DTests.cs b/tests/ComputeSharp.Tests/TransferTexture2DTests.cs
index be4dda0d..4ab2b901 100644
--- a/tests/ComputeSharp.Tests/TransferTexture2DTests.cs
+++ b/tests/ComputeSharp.Tests/TransferTexture2DTests.cs
@@ -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 uploadTexture2D = device.Get().AllocateUploadTexture2D(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(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 uploadTexture2D = device.Get().AllocateUploadTexture2D(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 sourceRow = uploadTexture2D.View.GetRowSpan(i + y).Slice(x, width);
- Span destinationRow = result.GetRowSpan(i).Slice(0, width);
+ for (int i = 0; i < height; i++)
+ {
+ Span sourceRow = uploadTexture2D.View.GetRowSpan(i + y).Slice(x, width);
+ Span destinationRow = new Span(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(p, source.Length).AsBytes());
}
using ReadOnlyTexture2D 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(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(p, source.Length).AsBytes());
}
using ReadOnlyTexture2D 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 sourceRow = source.GetRowSpan(i + y).Slice(x, width);
- Span destinationRow = readBackTexture2D.View.GetRowSpan(i).Slice(0, width);
+ for (int i = 0; i < height; i++)
+ {
+ Span sourceRow = new Span(Unsafe.AsPointer(ref source[i + y, 0]), source.GetLength(1)).Slice(x, width);
+ Span destinationRow = readBackTexture2D.View.GetRowSpan(i).Slice(0, width);
- Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
+ Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
+ }
}
}
}
diff --git a/tests/ComputeSharp.Tests/TransferTexture3DTests.cs b/tests/ComputeSharp.Tests/TransferTexture3DTests.cs
index c28bb6c6..2999795f 100644
--- a/tests/ComputeSharp.Tests/TransferTexture3DTests.cs
+++ b/tests/ComputeSharp.Tests/TransferTexture3DTests.cs
@@ -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 uploadTexture3D = device.Get().AllocateUploadTexture3D(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 sourceRow = uploadTexture3D.View.GetRowSpan(j, i);
- Span destinationRow = result.AsSpan2D(i).GetRowSpan(j);
+ for (int j = 0; j < uploadTexture3D.Height; j++)
+ {
+ Span sourceRow = uploadTexture3D.View.GetRowSpan(j, i);
+ Span 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 uploadTexture3D = device.Get().AllocateUploadTexture3D(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 sourceRow = uploadTexture3D.View.GetRowSpan(j + y, i + z).Slice(x, width);
- Span destinationRow = result.AsSpan2D(i).GetRowSpan(j).Slice(0, width);
+ for (int j = 0; j < height; j++)
+ {
+ Span sourceRow = uploadTexture3D.View.GetRowSpan(j + y, i + z).Slice(x, width);
+ Span destinationRow = new Span(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(p, source.Length).AsBytes());
}
using ReadOnlyTexture3D 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 sourceRow = source.AsSpan2D(i).GetRowSpan(j);
- Span destinationRow = readBackTexture3D.View.GetRowSpan(j, i);
+ for (int j = 0; j < readBackTexture3D.Height; j++)
+ {
+ Span sourceRow = new(Unsafe.AsPointer(ref source[i, j, 0]), source.GetLength(2));
+ Span 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(p, source.Length).AsBytes());
}
using ReadOnlyTexture3D 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 sourceRow = source.AsSpan2D(i + z).GetRowSpan(j + y).Slice(x, width);
- Span destinationRow = readBackTexture3D.View.GetRowSpan(j, i).Slice(0, width);
+ for (int j = 0; j < height; j++)
+ {
+ Span sourceRow = new Span(Unsafe.AsPointer(ref source[i + z, j + y, 0]), source.GetLength(2)).Slice(x, width);
+ Span destinationRow = readBackTexture3D.View.GetRowSpan(j, i).Slice(0, width);
- Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
+ Assert.IsTrue(sourceRow.SequenceEqual(destinationRow));
+ }
}
}
}