Merge pull request #164 from Sergio0694/feature/netstandard2_0-multi-target
Add .NET Standard 2.0 target
このコミットが含まれているのは:
745ファイル変更
+59437
-352
検索条件に一致するファイルはありません
+81
-31
@@ -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
|
||||
+78
-16
@@ -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}
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Company>Sergio Pedri</Company>
|
||||
<Copyright>Copyright (c) 2021 Sergio Pedri</Copyright>
|
||||
<NoWarn>$(NoWarn);MSB3270</NoWarn>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -205,8 +205,8 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
|
||||
// Fill in the complex kernel values
|
||||
Unsafe.Add(ref baseRef, i) = new Complex64(
|
||||
MathF.Exp(-a * value) * MathF.Cos(b * value),
|
||||
MathF.Exp(-a * value) * MathF.Sin(b * value));
|
||||
(float)(Math.Exp(-a * value) * Math.Cos(b * value)),
|
||||
(float)(Math.Exp(-a * value) * Math.Sin(b * value)));
|
||||
}
|
||||
|
||||
return kernel;
|
||||
@@ -245,7 +245,7 @@ public sealed partial class HlslBokehBlurProcessor
|
||||
}
|
||||
|
||||
// Normalize the kernels
|
||||
float scalar = 1f / MathF.Sqrt(total);
|
||||
float scalar = 1f / (float)Math.Sqrt(total);
|
||||
|
||||
for (int i = 0; i < kernelsSpan.Length; i++)
|
||||
{
|
||||
|
||||
@@ -80,13 +80,13 @@ public sealed partial class HlslGaussianBlurProcessor
|
||||
private static float Gaussian(float x, float sigma)
|
||||
{
|
||||
const float Numerator = 1.0f;
|
||||
float denominator = MathF.Sqrt(2 * MathF.PI) * sigma;
|
||||
float denominator = (float)(Math.Sqrt(2 * Math.PI) * sigma);
|
||||
|
||||
float exponentNumerator = -x * x;
|
||||
float exponentDenominator = 2 * sigma * sigma;
|
||||
|
||||
float left = Numerator / denominator;
|
||||
float right = MathF.Exp(exponentNumerator / exponentDenominator);
|
||||
float right = (float)Math.Exp(exponentNumerator / exponentDenominator);
|
||||
|
||||
return left * right;
|
||||
}
|
||||
|
||||
@@ -28,9 +28,16 @@ class Program
|
||||
using Image copy = image.Clone(c => c.ApplyProcessor(effect.Processor));
|
||||
|
||||
Console.WriteLine($">> Saving {effect.Name} to disk");
|
||||
string targetPath = Path.Combine(
|
||||
Path.GetRelativePath(Path.GetDirectoryName(path)!, @"..\..\..\"),
|
||||
$"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}");
|
||||
|
||||
string targetPath = Path.GetDirectoryName(path)!;
|
||||
|
||||
while (Path.GetFileName(targetPath) != "ComputeSharp.ImageProcessing")
|
||||
{
|
||||
targetPath = Path.GetDirectoryName(targetPath)!;
|
||||
}
|
||||
|
||||
targetPath = Path.Combine(targetPath, $"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}");
|
||||
|
||||
copy.Save(targetPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -59,7 +59,7 @@ partial class Program
|
||||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
var row = array[(i * width)..((i + 1) * width)];
|
||||
var row = array.AsSpan(i * width, width).ToArray();
|
||||
var text = string.Join(",", row.Select(x => x.ToString(CultureInfo.InvariantCulture).PadLeft(numberWidth)));
|
||||
|
||||
Console.WriteLine(text);
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>a5997814-d8d2-4541-87ac-c3e53caa67c0</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>ComputeSharp.NetStandard</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Collections.Generic\DictionaryExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Collections.Generic\QueueExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Enum.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\GC.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\IntPtrExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\FormatExtensions.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Path.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InterpolatedStringHandlerArgumentAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InterpolatedStringHandlerAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\SkipLocalsInitAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\MemoryMarshal.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\RuntimeHelpers.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\OSPlatformAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\SupportedOSVersionAttribute.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>a5997814-d8d2-4541-87ac-c3e53caa67c0</ProjectGuid>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
||||
<PropertyGroup />
|
||||
<Import Project="ComputeSharp.NetStandard.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// A helper type with extensions for the <see cref="Dictionary{TKey, TValue}"/> type.
|
||||
/// </summary>
|
||||
internal static class DictionaryExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Tries to remove an item from a <see cref="Dictionary{TKey, TValue}"/> instance and returns it if present.
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">The type of dictionary keys.</typeparam>
|
||||
/// <typeparam name="TValue">The type of dictionary values.</typeparam>
|
||||
/// <param name="dictionary">The input <see cref="Dictionary{TKey, TValue}"/> instance.</param>
|
||||
/// <param name="key">The lookup key to use.</param>
|
||||
/// <param name="value">The resulting item, if present.</param>
|
||||
/// <returns>Whether or not an item was found with the given key.</returns>
|
||||
public static bool Remove<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, out TValue? value)
|
||||
where TKey : notnull
|
||||
{
|
||||
if (dictionary.TryGetValue(key, out value))
|
||||
{
|
||||
_ = dictionary.Remove(key);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// A helper type with extensions for the <see cref="Queue{T}"/> type.
|
||||
/// </summary>
|
||||
internal static class QueueExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Tries to dequeue an item from the input <see cref="Queue{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items in the queue.</typeparam>
|
||||
/// <param name="queue">The input queue.</param>
|
||||
/// <param name="result">The resulting item, if any.</param>
|
||||
/// <returns>Whether or not an item was found.</returns>
|
||||
public static bool TryDequeue<T>(this Queue<T> queue, out T? result)
|
||||
{
|
||||
if (queue.Count > 0)
|
||||
{
|
||||
result = queue.Dequeue();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
result = default!;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace ComputeSharp.NetStandard.System;
|
||||
|
||||
/// <summary>
|
||||
/// A polyfill type that mirrors some methods from <see cref="global::System.Enum"/> on .NET 6.
|
||||
/// </summary>
|
||||
internal static class Enum
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the name of the input enum value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Specifies the type of the enum element.</typeparam>
|
||||
/// <param name="value">The input enum value.</param>
|
||||
/// <returns>The name of <paramref name="value"/>.</returns>
|
||||
public static string GetName<T>(T value)
|
||||
where T : unmanaged, global::System.Enum
|
||||
{
|
||||
return global::System.Enum.GetName(typeof(T), value)!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System;
|
||||
|
||||
/// <summary>
|
||||
/// A polyfill type with additional formatting extensions.
|
||||
/// </summary>
|
||||
internal static class FormatExtensions
|
||||
{
|
||||
/// <inheritdoc cref="IFormattable.ToString(string?, IFormatProvider?)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string ToString<T>(this T value, string? format)
|
||||
{
|
||||
throw new NotSupportedException("This API is not supported on this target.");
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IFormattable.ToString(string?, IFormatProvider?)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string ToString<T>(this T value, string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
throw new NotSupportedException("This API is not supported on this target.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace ComputeSharp.NetStandard.System;
|
||||
|
||||
/// <summary>
|
||||
/// A polyfill type that mirrors some methods from <see cref="global::System.GC"/> on .NET 6.
|
||||
/// </summary>
|
||||
internal static class GC
|
||||
{
|
||||
/// <summary>
|
||||
/// Allocate an array while skipping zero-initialization if possible.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Specifies the type of the array element.</typeparam>
|
||||
/// <param name="length">Specifies the length of the array.</param>
|
||||
/// <param name="pinned">Specifies whether the allocated array must be pinned.</param>
|
||||
/// <remarks>
|
||||
/// If pinned is set to true, <typeparamref name="T"/> must not be a reference type or a type that contains object references.
|
||||
/// </remarks>
|
||||
public static T[] AllocateUninitializedArray<T>(int length, bool pinned = false)
|
||||
{
|
||||
return new T[length];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System;
|
||||
|
||||
/// <summary>
|
||||
/// A polyfill type with extensions for <see cref="IntPtr"/> and <see cref="UIntPtr"/>.
|
||||
/// </summary>
|
||||
internal static class IntPtrExtensions
|
||||
{
|
||||
/// <inheritdoc cref="IComparable{T}.CompareTo(T)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int CompareTo(this nint left, nint right)
|
||||
{
|
||||
return left.CompareTo(right);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IComparable{T}.CompareTo(T)"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int CompareTo(this nuint left, nuint right)
|
||||
{
|
||||
return left.CompareTo(right);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.NetStandard.System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// A polyfill type that mirrors some methods from <see cref="global::System.IO.Path"/> on .NET 6.
|
||||
/// </summary>
|
||||
internal static class Path
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the extension of the given path.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The returned value is an empty <see cref="ReadOnlySpan{T}"/> if the given path does not include an extension.
|
||||
/// </remarks>
|
||||
public static ReadOnlySpan<char> GetExtension(ReadOnlySpan<char> path)
|
||||
{
|
||||
return global::System.IO.Path.GetExtension(path.ToString()).AsSpan();
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
namespace System.Runtime.CompilerServices;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates which arguments to a method involving an interpolated string handler should be passed to that handler.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InterpolatedStringHandlerArgumentAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="argument">The name of the argument that should be passed to the handler.</param>
|
||||
/// <remarks><see langword="null"/> may be used as the name of the receiver in an instance method.</remarks>
|
||||
public InterpolatedStringHandlerArgumentAttribute(string argument) => Arguments = new string[] { argument };
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InterpolatedStringHandlerArgumentAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="arguments">The names of the arguments that should be passed to the handler.</param>
|
||||
/// <remarks><see langword="null"/> may be used as the name of the receiver in an instance method.</remarks>
|
||||
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments) => Arguments = arguments;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the names of the arguments that should be passed to the handler.
|
||||
/// </summary>
|
||||
/// <remarks><see langword="null"/> may be used as the name of the receiver in an instance method.</remarks>
|
||||
public string[] Arguments { get; }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
namespace System.Runtime.CompilerServices;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the attributed type is to be used as an interpolated string handler.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class InterpolatedStringHandlerAttribute : Attribute
|
||||
{
|
||||
}
|
||||
+5
-4
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Helpers;
|
||||
namespace ComputeSharp.NetStandard.System.Runtime.CompilerServices;
|
||||
|
||||
/// <summary>
|
||||
/// A polyfill type that mirrors some methods from <see cref="System.Runtime.CompilerServices.RuntimeHelpers"/> on .NET 5.
|
||||
/// A polyfill type that mirrors some methods from <see cref="RuntimeHelpers"/> on .NET 5.
|
||||
/// </summary>
|
||||
internal static class RuntimeHelpers
|
||||
{
|
||||
@@ -13,5 +14,5 @@ internal static class RuntimeHelpers
|
||||
/// <param name="type">The type to associate the memory to.</param>
|
||||
/// <param name="size">The size in byte of the memory to allocate.</param>
|
||||
/// <returns>A pointer to the allocated memory.</returns>
|
||||
public static IntPtr AllocateTypeAssociatedMemory(Type type, int size) => default;
|
||||
}
|
||||
public static IntPtr AllocateTypeAssociatedMemory(Type type, int size) => Marshal.AllocHGlobal(size);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace System.Runtime.CompilerServices;
|
||||
|
||||
/// <summary>
|
||||
/// Used to indicate to the compiler that the <c>.locals init</c>
|
||||
/// flag should not be set in method headers.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Module
|
||||
| AttributeTargets.Class
|
||||
| AttributeTargets.Struct
|
||||
| AttributeTargets.Interface
|
||||
| AttributeTargets.Constructor
|
||||
| AttributeTargets.Method
|
||||
| AttributeTargets.Property
|
||||
| AttributeTargets.Event, Inherited = false)]
|
||||
internal sealed class SkipLocalsInitAttribute : Attribute
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ComputeSharp.NetStandard.System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// A polyfill type that mirrors some methods from <see cref="MemoryMarshal"/> on .NET 6.
|
||||
/// </summary>
|
||||
internal static class MemoryMarshal
|
||||
{
|
||||
/// <inheritdoc cref="global::System.Runtime.InteropServices.MemoryMarshal.GetReference{T}(Span{T})"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ref T GetReference<T>(Span<T> span)
|
||||
{
|
||||
return ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(span);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="global::System.Runtime.InteropServices.MemoryMarshal.GetReference{T}(ReadOnlySpan{T})"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ref T GetReference<T>(ReadOnlySpan<T> span)
|
||||
{
|
||||
return ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a reference to the 0th element of <paramref name="array"/>. 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.
|
||||
/// </summary>
|
||||
/// <exception cref="NullReferenceException"><paramref name="array"/> is <see langword="null"/>.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ref T GetArrayDataReference<T>(T[] array)
|
||||
{
|
||||
return ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(array.AsSpan());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Span{T}"/> from a given reference.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of reference to wrap.</typeparam>
|
||||
/// <param name="value">The target reference.</param>
|
||||
/// <param name="length">The length of the <see cref="Span{T}"/> to create.</param>
|
||||
/// <returns>A new <see cref="Span{T}"/> wrapping <paramref name="value"/>.</returns>
|
||||
public static unsafe Span<T> CreateSpan<T>(ref T value, int length)
|
||||
{
|
||||
return new(Unsafe.AsPointer(ref value), length);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace System.Runtime.Versioning;
|
||||
|
||||
/// <summary>
|
||||
/// Base type for all platform-specific API attributes.
|
||||
/// </summary>
|
||||
|
||||
internal abstract class OSPlatformAttribute : Attribute
|
||||
{
|
||||
private protected OSPlatformAttribute(string platformName)
|
||||
{
|
||||
PlatformName = platformName;
|
||||
}
|
||||
|
||||
public string PlatformName { get; }
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace System.Runtime.Versioning;
|
||||
|
||||
/// <summary>
|
||||
/// Records the operating system (and minimum version) that supports an API. Multiple
|
||||
/// attributes can be applied to indicate support on multiple operating systems.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Callers can apply a <see cref="SupportedOSPlatformAttribute " />
|
||||
/// or use guards to prevent calls to APIs on unsupported operating systems.
|
||||
/// A given platform should only be specified once.
|
||||
/// </remarks>
|
||||
[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)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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.-->
|
||||
<ItemGroup>
|
||||
<Compile Include="..\ComputeSharp.NetStandard\System\Runtime\CompilerServices\RuntimeHelpers.cs" Link="Helpers\RuntimeHelpers.cs" />
|
||||
<Compile Include="..\ComputeSharp.NetStandard\System\Runtime\InteropServices\MemoryMarshal.cs" Link="Helpers\MemoryMarshal.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Attributes\AutoConstructorAttribute.cs" Link="Core\Attributes\AutoConstructorAttribute.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Attributes\GroupSharedAttribute.cs" Link="Core\Attributes\GroupSharedAttribute.cs" />
|
||||
<Compile Include="..\ComputeSharp\Core\Attributes\ShaderMethodAttribute.cs" Link="Core\Attributes\ShaderMethodAttribute.cs" />
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// A polyfill type that mirrors some methods from <see cref="System.Runtime.InteropServices.MemoryMarshal"/> on .NET 5.
|
||||
/// </summary>
|
||||
internal static class MemoryMarshal
|
||||
{
|
||||
/// <inheritdoc cref="System.Runtime.InteropServices.MemoryMarshal.GetReference{T}(Span{T})"/>
|
||||
public static ref T GetReference<T>(Span<T> span)
|
||||
{
|
||||
return ref System.Runtime.InteropServices.MemoryMarshal.GetReference(span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Span{T}"/> from a given reference.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of reference to wrap.</typeparam>
|
||||
/// <param name="value">The target reference.</param>
|
||||
/// <param name="length">The length of the <see cref="Span{T}"/> to create.</param>
|
||||
/// <returns>A new <see cref="Span{T}"/> wrapping <paramref name="value"/>.</returns>
|
||||
public static Span<T> CreateSpan<T>(ref T value, int length) => default;
|
||||
}
|
||||
@@ -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")))));
|
||||
}
|
||||
|
||||
@@ -1,17 +1,43 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<DocumentationFile>ComputeSharp.xml</DocumentationFile>
|
||||
<Description>ComputeSharp</Description>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Toolkit.Diagnostics" Version="7.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- .NET 6 uses the NuGet packages for TerraFX -->
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
|
||||
<PackageReference Include="TerraFX.Interop.D3D12MemoryAllocator" Version="2.0.0-beta3" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- .NET Standard 2.0 uses a local fork -->
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Shared project with .NET Standard 2.0 polyfills -->
|
||||
<Import Condition="'$(TargetFramework)' == 'netstandard2.0'"
|
||||
Project="..\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems"
|
||||
Label="Shared" />
|
||||
|
||||
<!-- Shared project with TerraFX.Interop.Windows fork -->
|
||||
<Import Condition="'$(TargetFramework)' == 'netstandard2.0'"
|
||||
Project="..\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems"
|
||||
Label="Shared" />
|
||||
|
||||
<!-- Ignore the warnings on the .NET Standard 2.0 profile -->
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Choose>
|
||||
|
||||
<!-- When building locally for x64/ARM64 (using the project through a project reference),
|
||||
|
||||
+29
-2
@@ -24,7 +24,7 @@ internal ref struct FormatInterpolatedStringHandler
|
||||
private readonly string? format;
|
||||
|
||||
/// <summary>
|
||||
/// Optional provider to pass to <see cref="IFormattable.ToString(string?, IFormatProvider?)"/> or <see cref="ISpanFormattable.TryFormat(Span{char}, out int, ReadOnlySpan{char}, IFormatProvider?)"/> calls.
|
||||
/// Optional provider to pass to <see cref="IFormattable.ToString(string?, IFormatProvider?)"/> calls.
|
||||
/// </summary>
|
||||
private readonly IFormatProvider? formatProvider;
|
||||
|
||||
@@ -95,7 +95,11 @@ internal ref struct FormatInterpolatedStringHandler
|
||||
/// </remarks>
|
||||
public string ToStringAndClear()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
string result = new(characters.Slice(0, position));
|
||||
#else
|
||||
string result = characters.Slice(0, position).ToString();
|
||||
#endif
|
||||
char[]? toReturn = arrayToReturnToPool;
|
||||
|
||||
this = default;
|
||||
@@ -142,7 +146,11 @@ internal ref struct FormatInterpolatedStringHandler
|
||||
{
|
||||
Unsafe.WriteUnaligned(
|
||||
ref Unsafe.As<char, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(chars), pos)),
|
||||
#if NET6_0_OR_GREATER
|
||||
Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.AsRef(in value.GetPinnableReference()))));
|
||||
#else
|
||||
Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(value.AsSpan()))));
|
||||
#endif
|
||||
|
||||
position = pos + 2;
|
||||
}
|
||||
@@ -162,7 +170,11 @@ internal ref struct FormatInterpolatedStringHandler
|
||||
/// <param name="value">The string to write.</param>
|
||||
private void AppendStringDirect(string value)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
if (value.TryCopyTo(characters.Slice(position)))
|
||||
#else
|
||||
if (value.AsSpan().TryCopyTo(characters.Slice(position)))
|
||||
#endif
|
||||
{
|
||||
position += value.Length;
|
||||
}
|
||||
@@ -186,7 +198,11 @@ internal ref struct FormatInterpolatedStringHandler
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
public void AppendFormatted<T>(T value)
|
||||
#if NET6_0_OR_GREATER
|
||||
where T : ISpanFormattable
|
||||
#else
|
||||
where T : IFormattable
|
||||
#endif
|
||||
{
|
||||
if (hasCustomFormatter)
|
||||
{
|
||||
@@ -194,6 +210,7 @@ internal ref struct FormatInterpolatedStringHandler
|
||||
return;
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
int charsWritten;
|
||||
|
||||
while (!value.TryFormat(characters.Slice(position), out charsWritten, format, formatProvider))
|
||||
@@ -202,6 +219,9 @@ internal ref struct FormatInterpolatedStringHandler
|
||||
}
|
||||
|
||||
position += charsWritten;
|
||||
#else
|
||||
AppendStringDirect(value.ToString(format, formatProvider));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -222,7 +242,6 @@ internal ref struct FormatInterpolatedStringHandler
|
||||
/// <param name="format">The format string.</param>
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void AppendCustomFormatter<T>(T value, string? format)
|
||||
where T : ISpanFormattable
|
||||
{
|
||||
ICustomFormatter? formatter = (ICustomFormatter?)formatProvider?.GetFormat(typeof(ICustomFormatter));
|
||||
|
||||
@@ -241,7 +260,11 @@ internal ref struct FormatInterpolatedStringHandler
|
||||
{
|
||||
Grow(value.Length);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
value.CopyTo(characters.Slice(position));
|
||||
#else
|
||||
value.AsSpan().CopyTo(characters.Slice(position));
|
||||
#endif
|
||||
|
||||
position += value.Length;
|
||||
}
|
||||
@@ -271,7 +294,11 @@ internal ref struct FormatInterpolatedStringHandler
|
||||
private void GrowCore(uint requiredMinCapacity)
|
||||
{
|
||||
uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)characters.Length * 2, 0x3FFFFFDF));
|
||||
#if NET6_0_OR_GREATER
|
||||
int arraySize = (int)Math.Clamp(newCapacity, MinimumArrayPoolLength, int.MaxValue);
|
||||
#else
|
||||
int arraySize = (int)Math.Min(Math.Max(newCapacity, MinimumArrayPoolLength), int.MaxValue);
|
||||
#endif
|
||||
char[] newArray = ArrayPool<char>.Shared.Rent(arraySize);
|
||||
|
||||
characters.Slice(0, position).CopyTo(newArray);
|
||||
|
||||
+21
-1
@@ -27,7 +27,7 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
|
||||
private string? formatAsString;
|
||||
|
||||
/// <summary>
|
||||
/// Optional provider to pass to <see cref="IFormattable.ToString(string?, IFormatProvider?)"/> or <see cref="ISpanFormattable.TryFormat(Span{char}, out int, ReadOnlySpan{char}, IFormatProvider?)"/> calls.
|
||||
/// Optional provider to pass to <see cref="IFormattable.ToString(string?, IFormatProvider?)"/> calls.
|
||||
/// </summary>
|
||||
private readonly IFormatProvider? formatProvider;
|
||||
|
||||
@@ -129,7 +129,11 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
|
||||
{
|
||||
Unsafe.WriteUnaligned(
|
||||
ref Unsafe.As<char, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(destination), pos)),
|
||||
#if NET6_0_OR_GREATER
|
||||
Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.AsRef(in value.GetPinnableReference()))));
|
||||
#else
|
||||
Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(value.AsSpan()))));
|
||||
#endif
|
||||
|
||||
position = pos + 2;
|
||||
|
||||
@@ -149,7 +153,11 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
|
||||
/// <returns>Whether the value could be appended to the span.</returns>
|
||||
private bool AppendStringDirect(string value)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
if (value.TryCopyTo(destination.Slice(position)))
|
||||
#else
|
||||
if (value.AsSpan().TryCopyTo(destination.Slice(position)))
|
||||
#endif
|
||||
{
|
||||
position += value.Length;
|
||||
return true;
|
||||
@@ -163,13 +171,18 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
|
||||
/// </summary>
|
||||
/// <param name="value">The value to write.</param>
|
||||
public bool AppendFormatted<T>(T value)
|
||||
#if NET6_0_OR_GREATER
|
||||
where T : ISpanFormattable
|
||||
#else
|
||||
where T : IFormattable
|
||||
#endif
|
||||
{
|
||||
if (hasCustomFormatter)
|
||||
{
|
||||
return AppendCustomFormatter(value, formatAsString ??= format.ToString());
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
int charsWritten;
|
||||
|
||||
if (value.TryFormat(destination.Slice(position), out charsWritten, format, formatProvider))
|
||||
@@ -180,6 +193,9 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
|
||||
}
|
||||
|
||||
return Fail();
|
||||
#else
|
||||
return AppendStringDirect(value.ToString(formatAsString ??= format.ToString(), formatProvider));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -198,7 +214,11 @@ internal ref struct TryWriteFormatInterpolatedStringHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
if (value.TryCopyTo(destination.Slice(position)))
|
||||
#else
|
||||
if (value.AsSpan().TryCopyTo(destination.Slice(position)))
|
||||
#endif
|
||||
{
|
||||
position += value.Length;
|
||||
|
||||
|
||||
@@ -17,9 +17,13 @@ public interface IShader
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be used directly by user code")]
|
||||
int GetDispatchId()
|
||||
#if NET6_0_OR_GREATER
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Loads the dispatch data for the shader.
|
||||
@@ -34,9 +38,13 @@ public interface IShader
|
||||
[Obsolete("This method is not intended to be called directly by user code")]
|
||||
void LoadDispatchData<TDataLoader>(ref TDataLoader loader, GraphicsDevice device, int x, int y, int z)
|
||||
where TDataLoader : struct, IDispatchDataLoader
|
||||
#if NET6_0_OR_GREATER
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Loads an opaque metadata handle from the metadata of the current shader.
|
||||
@@ -48,9 +56,13 @@ public interface IShader
|
||||
[Obsolete("This method is not intended to be called directly by user code")]
|
||||
void LoadDispatchMetadata<TMetadataLoader>(ref TMetadataLoader loader, out IntPtr result)
|
||||
where TMetadataLoader : struct, IDispatchMetadataLoader
|
||||
#if NET6_0_OR_GREATER
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Builds the HLSL source code for the current shader instance.
|
||||
@@ -62,7 +74,11 @@ public interface IShader
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be called directly by user code")]
|
||||
void BuildHlslString(out ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ)
|
||||
#if NET6_0_OR_GREATER
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
}
|
||||
@@ -18,7 +18,10 @@ namespace ComputeSharp;
|
||||
/// </summary>
|
||||
/// <remarks>This struct is fully mutable.</remarks>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Bgra32 : IEquatable<Bgra32>, ISpanFormattable, IUnorm<Vector4>, IUnorm<Float4>
|
||||
public struct Bgra32 : IEquatable<Bgra32>, IUnorm<Vector4>, IUnorm<Float4>
|
||||
#if NET6_0_OR_GREATER
|
||||
, ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// The blue component.
|
||||
@@ -119,6 +122,7 @@ public struct Bgra32 : IEquatable<Bgra32>, ISpanFormattable, IUnorm<Vector4>, IU
|
||||
/// <inheritdoc />
|
||||
public override readonly string ToString() => $"{nameof(Bgra32)}({this.B}, {this.G}, {this.R}, {this.A})";
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc />
|
||||
public string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
@@ -130,4 +134,5 @@ public struct Bgra32 : IEquatable<Bgra32>, ISpanFormattable, IUnorm<Vector4>, IU
|
||||
{
|
||||
return destination.TryWrite(provider, $"{nameof(Bgra32)}({this.B}, {this.G}, {this.R}, {this.A})", out charsWritten);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -14,7 +14,10 @@ namespace ComputeSharp;
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct R16 : IEquatable<R16>, ISpanFormattable, IUnorm<float>
|
||||
public struct R16 : IEquatable<R16>, IUnorm<float>
|
||||
#if NET6_0_OR_GREATER
|
||||
, ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
@@ -78,6 +81,7 @@ public struct R16 : IEquatable<R16>, ISpanFormattable, IUnorm<float>
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(R16)}({this.R})";
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
public string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
@@ -88,5 +92,6 @@ public struct R16 : IEquatable<R16>, ISpanFormattable, IUnorm<float>
|
||||
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
return destination.TryWrite(provider, $"{nameof(R16)}({this.R})", out charsWritten);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -14,7 +14,10 @@ namespace ComputeSharp;
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct R8 : IEquatable<R8>, ISpanFormattable, IUnorm<float>
|
||||
public struct R8 : IEquatable<R8>, IUnorm<float>
|
||||
#if NET6_0_OR_GREATER
|
||||
, ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
@@ -78,6 +81,7 @@ public struct R8 : IEquatable<R8>, ISpanFormattable, IUnorm<float>
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(R8)}({this.R})";
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
public string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
@@ -89,4 +93,5 @@ public struct R8 : IEquatable<R8>, ISpanFormattable, IUnorm<float>
|
||||
{
|
||||
return destination.TryWrite(provider, $"{nameof(R8)}({this.R})", out charsWritten);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -15,7 +15,10 @@ namespace ComputeSharp;
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Rg16 : IEquatable<Rg16>, ISpanFormattable, IUnorm<Vector2>, IUnorm<Float2>
|
||||
public struct Rg16 : IEquatable<Rg16>, IUnorm<Vector2>, IUnorm<Float2>
|
||||
#if NET6_0_OR_GREATER
|
||||
, ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
@@ -86,6 +89,7 @@ public struct Rg16 : IEquatable<Rg16>, ISpanFormattable, IUnorm<Vector2>, IUnorm
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(Rg16)}({this.R}, {this.G})";
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
public string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
@@ -97,4 +101,5 @@ public struct Rg16 : IEquatable<Rg16>, ISpanFormattable, IUnorm<Vector2>, IUnorm
|
||||
{
|
||||
return destination.TryWrite(provider, $"{nameof(Rg16)}({this.R}, {this.G})", out charsWritten);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -15,7 +15,10 @@ namespace ComputeSharp;
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Rg32 : IEquatable<Rg32>, ISpanFormattable, IUnorm<Vector2>, IUnorm<Float2>
|
||||
public struct Rg32 : IEquatable<Rg32>, IUnorm<Vector2>, IUnorm<Float2>
|
||||
#if NET6_0_OR_GREATER
|
||||
, ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
@@ -86,6 +89,7 @@ public struct Rg32 : IEquatable<Rg32>, ISpanFormattable, IUnorm<Vector2>, IUnorm
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(Rg32)}({this.R}, {this.G})";
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
public string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
@@ -97,4 +101,5 @@ public struct Rg32 : IEquatable<Rg32>, ISpanFormattable, IUnorm<Vector2>, IUnorm
|
||||
{
|
||||
return destination.TryWrite(provider, $"{nameof(Rg32)}({this.R}, {this.G})", out charsWritten);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -17,7 +17,10 @@ namespace ComputeSharp;
|
||||
/// </summary>
|
||||
/// <remarks>This struct is fully mutable.</remarks>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Rgba32 : IEquatable<Rgba32>, ISpanFormattable, IUnorm<Vector4>, IUnorm<Float4>
|
||||
public struct Rgba32 : IEquatable<Rgba32>, IUnorm<Vector4>, IUnorm<Float4>
|
||||
#if NET6_0_OR_GREATER
|
||||
, ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
@@ -118,6 +121,7 @@ public struct Rgba32 : IEquatable<Rgba32>, ISpanFormattable, IUnorm<Vector4>, IU
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(Rgba32)}({this.R}, {this.G}, {this.B}, {this.A})";
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
public string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
@@ -129,4 +133,5 @@ public struct Rgba32 : IEquatable<Rgba32>, ISpanFormattable, IUnorm<Vector4>, IU
|
||||
{
|
||||
return destination.TryWrite(provider, $"{nameof(Rgba32)}({this.R}, {this.G}, {this.B}, {this.A})", out charsWritten);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -17,7 +17,10 @@ namespace ComputeSharp;
|
||||
/// </summary>
|
||||
/// <remarks>This struct is fully mutable.</remarks>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Rgba64 : IEquatable<Rgba64>, ISpanFormattable, IUnorm<Vector4>, IUnorm<Float4>
|
||||
public struct Rgba64 : IEquatable<Rgba64>, IUnorm<Vector4>, IUnorm<Float4>
|
||||
#if NET6_0_OR_GREATER
|
||||
, ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
@@ -118,6 +121,7 @@ public struct Rgba64 : IEquatable<Rgba64>, ISpanFormattable, IUnorm<Vector4>, IU
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(Rgba64)}({this.R}, {this.G}, {this.B}, {this.A})";
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
public string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
@@ -129,4 +133,5 @@ public struct Rgba64 : IEquatable<Rgba64>, ISpanFormattable, IUnorm<Vector4>, IU
|
||||
{
|
||||
return destination.TryWrite(provider, $"{nameof(Rgba64)}({this.R}, {this.G}, {this.B}, {this.A})", out charsWritten);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -48,14 +48,12 @@ public readonly struct Bool
|
||||
return Value.ToString();
|
||||
}
|
||||
|
||||
#if !SOURCE_GENERATOR
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc cref="bool.TryFormat(Span{char}, out int)"/>
|
||||
public bool TryFormat(Span<char> destination, out int charsWritten)
|
||||
{
|
||||
return Value.TryFormat(destination, out charsWritten);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -392,7 +392,11 @@ public unsafe partial struct Bool2
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[32], $"<{this.x}, {this.y}>");
|
||||
#else
|
||||
return $"<{this.x}, {this.y}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -1473,7 +1473,11 @@ public unsafe partial struct Bool3
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[32], $"<{this.x}, {this.y}, {this.z}>");
|
||||
#else
|
||||
return $"<{this.x}, {this.y}, {this.z}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -4114,7 +4114,11 @@ public unsafe partial struct Bool4
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[32], $"<{this.x}, {this.y}, {this.z}, {this.w}>");
|
||||
#else
|
||||
return $"<{this.x}, {this.y}, {this.z}, {this.w}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Double2"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)]
|
||||
public unsafe partial struct Double2
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -399,7 +399,11 @@ public unsafe partial struct Double2
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Double3"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 24, Pack = 8)]
|
||||
public unsafe partial struct Double3
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -1480,7 +1480,11 @@ public unsafe partial struct Double3
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Double4"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 32, Pack = 8)]
|
||||
public unsafe partial struct Double4
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -4121,7 +4121,11 @@ public unsafe partial struct Double4
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Float2"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
|
||||
public unsafe partial struct Float2
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -399,7 +399,11 @@ public unsafe partial struct Float2
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Float3"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)]
|
||||
public unsafe partial struct Float3
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -1480,7 +1480,11 @@ public unsafe partial struct Float3
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Float4"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)]
|
||||
public unsafe partial struct Float4
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -4121,7 +4121,11 @@ public unsafe partial struct Float4
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Int2"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
|
||||
public unsafe partial struct Int2
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -399,7 +399,11 @@ public unsafe partial struct Int2
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Int3"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)]
|
||||
public unsafe partial struct Int3
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -1480,7 +1480,11 @@ public unsafe partial struct Int3
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="Int4"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)]
|
||||
public unsafe partial struct Int4
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -4121,7 +4121,11 @@ public unsafe partial struct Int4
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -12,9 +12,9 @@ void GenerateAllMatrixProperties(string typeName, int elementSize)
|
||||
#>
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="UInt2"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
|
||||
public unsafe partial struct UInt2
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -399,7 +399,11 @@ public unsafe partial struct UInt2
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="UInt3"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)]
|
||||
public unsafe partial struct UInt3
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -1480,7 +1480,11 @@ public unsafe partial struct UInt3
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp;
|
||||
/// <inheritdoc cref="UInt4"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)]
|
||||
public unsafe partial struct UInt4
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: ISpanFormattable
|
||||
#endif
|
||||
{
|
||||
@@ -4121,7 +4121,11 @@ public unsafe partial struct UInt4
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>");
|
||||
#else
|
||||
return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -60,9 +60,9 @@ void GenerateVectorProperties(string typeName, int elementSize)
|
||||
#>
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if !NET6_0
|
||||
using RuntimeHelpers = ComputeSharp.SourceGenerators.Helpers.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.SourceGenerators.Helpers.MemoryMarshal;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#nullable enable
|
||||
@@ -76,7 +76,7 @@ public unsafe partial struct <#=typeName#>
|
||||
if (formattable != "")
|
||||
{
|
||||
#>
|
||||
#if !SOURCE_GENERATOR
|
||||
#if NET6_0_OR_GREATER
|
||||
: <#=formattable#>
|
||||
#endif
|
||||
<#
|
||||
@@ -167,7 +167,11 @@ public unsafe partial struct <#=typeName#>
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[32], $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>");
|
||||
#else
|
||||
return $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>";
|
||||
#endif
|
||||
}
|
||||
<#
|
||||
}
|
||||
@@ -179,7 +183,11 @@ public unsafe partial struct <#=typeName#>
|
||||
{
|
||||
string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
return string.Create(null, stackalloc char[64], $"<<#=string.Join("{separator} ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>");
|
||||
#else
|
||||
return $"<<#=string.Join("{separator} ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>";
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -4,6 +4,9 @@ using Microsoft.Toolkit.Diagnostics;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_DESCRIPTOR_HEAP_TYPE;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using GC = ComputeSharp.NetStandard.System.GC;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp.Graphics.Commands.Interop;
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Resources;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using GC = ComputeSharp.NetStandard.System.GC;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Diagnostics.Contracts;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Resources;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
@@ -1070,6 +1071,24 @@ public static partial class GraphicsDeviceExtensions
|
||||
return new(device, width, height, depth, allocationMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a new readonly 2D texture with the contents of the specified file.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="filename">The filename of the image file to load and decode into the texture.</param>
|
||||
/// <returns>A <see cref="ReadOnlyTexture2D{T, TPixel}"/> instance with the contents of the specified file.</returns>
|
||||
[Pure]
|
||||
public static ReadOnlyTexture2D<T, TPixel> LoadReadOnlyTexture2D<T, TPixel>(this GraphicsDevice device, string filename)
|
||||
where T : unmanaged, IUnorm<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(filename, nameof(filename));
|
||||
|
||||
return device.LoadReadOnlyTexture2D<T, TPixel>(filename.AsSpan());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a new readonly 2D texture with the contents of the specified file.
|
||||
/// </summary>
|
||||
@@ -1114,6 +1133,24 @@ public static partial class GraphicsDeviceExtensions
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a new writeable 2D texture with the contents of the specified file.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> instance to use to allocate the texture.</param>
|
||||
/// <param name="filename">The filename of the image file to load and decode into the texture.</param>
|
||||
/// <returns>A <see cref="ReadWriteTexture2D{T, TPixel}"/> instance with the contents of the specified file.</returns>
|
||||
[Pure]
|
||||
public static ReadWriteTexture2D<T, TPixel> LoadReadWriteTexture2D<T, TPixel>(this GraphicsDevice device, string filename)
|
||||
where T : unmanaged, IUnorm<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(filename, nameof(filename));
|
||||
|
||||
return device.LoadReadWriteTexture2D<T, TPixel>(filename.AsSpan());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a new writeable 2D texture with the contents of the specified file.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using ComputeSharp.Core.Extensions;
|
||||
#if NET6_0_OR_GREATER
|
||||
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
@@ -196,3 +198,5 @@ internal static unsafe class AllocatorExtensions
|
||||
return allocation.Move();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,16 +1,34 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Runtime.CompilerServices;
|
||||
#endif
|
||||
using ComputeSharp.Core.Extensions;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using ComputeSharp.Graphics.Resources.Enums;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
#endif
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_COMMAND_QUEUE_FLAGS;
|
||||
using static TerraFX.Interop.DirectX.D3D12_COMMAND_QUEUE_PRIORITY;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using static TerraFX.Interop.DirectX.D3D12_CPU_PAGE_PROPERTY;
|
||||
#endif
|
||||
using static TerraFX.Interop.DirectX.D3D12_DESCRIPTOR_HEAP_FLAGS;
|
||||
using static TerraFX.Interop.DirectX.D3D12_DESCRIPTOR_HEAP_TYPE;
|
||||
using static TerraFX.Interop.DirectX.D3D12_FEATURE;
|
||||
using static TerraFX.Interop.DirectX.D3D12_FENCE_FLAGS;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using static TerraFX.Interop.DirectX.D3D12_HEAP_FLAGS;
|
||||
using static TerraFX.Interop.DirectX.D3D12_MEMORY_POOL;
|
||||
#endif
|
||||
using static TerraFX.Interop.DirectX.D3D12_MESSAGE_ID;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using static TerraFX.Interop.DirectX.D3D12_HEAP_TYPE;
|
||||
using static TerraFX.Interop.DirectX.D3D12_RESOURCE_FLAGS;
|
||||
using static TerraFX.Interop.DirectX.D3D12_RESOURCE_STATES;
|
||||
#endif
|
||||
using static TerraFX.Interop.DirectX.D3D12_SRV_DIMENSION;
|
||||
using static TerraFX.Interop.DirectX.D3D12_UAV_DIMENSION;
|
||||
|
||||
@@ -21,6 +39,7 @@ namespace ComputeSharp.Graphics.Extensions;
|
||||
/// </summary>
|
||||
internal static unsafe class ID3D12DeviceExtensions
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Creates a <see cref="D3D12MA_Allocator"/> instance for a given device.
|
||||
/// </summary>
|
||||
@@ -39,6 +58,198 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
|
||||
return allocator.Move();
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// Creates a committed resource for a given buffer type.
|
||||
/// </summary>
|
||||
/// <param name="d3D12Device">The <see cref="ID3D12Device"/> instance in use.</param>
|
||||
/// <param name="resourceType">The resource type currently in use.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <param name="sizeInBytes">The size in bytes of the current buffer.</param>
|
||||
/// <param name="isCacheCoherentUMA">Indicates whether or not the current device has a cache coherent UMA architecture.</param>
|
||||
/// <returns>An <see cref="ID3D12Resource"/> reference for the current buffer.</returns>
|
||||
public static ComPtr<ID3D12Resource> CreateCommittedResource(
|
||||
this ref ID3D12Device d3D12Device,
|
||||
ResourceType resourceType,
|
||||
AllocationMode allocationMode,
|
||||
ulong sizeInBytes,
|
||||
bool isCacheCoherentUMA)
|
||||
{
|
||||
(D3D12_HEAP_TYPE d3D12HeapType,
|
||||
D3D12_RESOURCE_FLAGS d3D12ResourceFlags,
|
||||
D3D12_RESOURCE_STATES d3D12ResourceStates) = resourceType switch
|
||||
{
|
||||
ResourceType.Constant => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
|
||||
ResourceType.ReadOnly => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadBack => (D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST),
|
||||
ResourceType.Upload => (D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_HEAP_TYPE, D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
};
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = default;
|
||||
|
||||
D3D12_HEAP_PROPERTIES d3D12HeapProperties;
|
||||
d3D12HeapProperties.CreationNodeMask = 1;
|
||||
d3D12HeapProperties.VisibleNodeMask = 1;
|
||||
|
||||
if (isCacheCoherentUMA)
|
||||
{
|
||||
d3D12HeapProperties.Type = D3D12_HEAP_TYPE_CUSTOM;
|
||||
d3D12HeapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_WRITE_BACK;
|
||||
d3D12HeapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_L0;
|
||||
}
|
||||
else
|
||||
{
|
||||
d3D12HeapProperties.Type = d3D12HeapType;
|
||||
d3D12HeapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||
d3D12HeapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||
}
|
||||
|
||||
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Buffer(sizeInBytes, d3D12ResourceFlags);
|
||||
|
||||
d3D12Device.CreateCommittedResource(
|
||||
&d3D12HeapProperties,
|
||||
D3D12_HEAP_FLAG_NONE,
|
||||
&d3D12ResourceDescription,
|
||||
d3D12ResourceStates,
|
||||
null,
|
||||
Windows.__uuidof<ID3D12Resource>(),
|
||||
d3D12Resource.GetVoidAddressOf()).Assert();
|
||||
|
||||
return d3D12Resource.Move();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a committed resource for a given 2D texture type.
|
||||
/// </summary>
|
||||
/// <param name="d3D12Device">The <see cref="ID3D12Device"/> instance in use.</param>
|
||||
/// <param name="resourceType">The resource type currently in use.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> value to use.</param>
|
||||
/// <param name="width">The width of the texture resource.</param>
|
||||
/// <param name="height">The height of the texture resource.</param>
|
||||
/// <param name="isCacheCoherentUMA">Indicates whether or not the current device has a cache coherent UMA architecture.</param>
|
||||
/// <param name="d3D12ResourceStates">The default <see cref="D3D12_RESOURCE_STATES"/> value for the resource.</param>
|
||||
/// <returns>An <see cref="ID3D12Resource"/> reference for the current texture.</returns>
|
||||
public static ComPtr<ID3D12Resource> CreateCommittedResource(
|
||||
this ref ID3D12Device d3D12Device,
|
||||
ResourceType resourceType,
|
||||
AllocationMode allocationMode,
|
||||
DXGI_FORMAT dxgiFormat,
|
||||
uint width,
|
||||
uint height,
|
||||
bool isCacheCoherentUMA,
|
||||
out D3D12_RESOURCE_STATES d3D12ResourceStates)
|
||||
{
|
||||
D3D12_RESOURCE_FLAGS d3D12ResourceFlags;
|
||||
|
||||
(d3D12ResourceFlags, d3D12ResourceStates) = resourceType switch
|
||||
{
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
};
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = default;
|
||||
|
||||
D3D12_HEAP_PROPERTIES d3D12HeapProperties;
|
||||
d3D12HeapProperties.CreationNodeMask = 1;
|
||||
d3D12HeapProperties.VisibleNodeMask = 1;
|
||||
|
||||
if (isCacheCoherentUMA)
|
||||
{
|
||||
d3D12HeapProperties.Type = D3D12_HEAP_TYPE_CUSTOM;
|
||||
d3D12HeapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_WRITE_BACK;
|
||||
d3D12HeapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_L0;
|
||||
}
|
||||
else
|
||||
{
|
||||
d3D12HeapProperties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||
d3D12HeapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||
d3D12HeapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||
}
|
||||
|
||||
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex2D(dxgiFormat, width, height, mipLevels: 1, flags: d3D12ResourceFlags);
|
||||
|
||||
d3D12Device.CreateCommittedResource(
|
||||
&d3D12HeapProperties,
|
||||
D3D12_HEAP_FLAG_NONE,
|
||||
&d3D12ResourceDescription,
|
||||
d3D12ResourceStates,
|
||||
null,
|
||||
Windows.__uuidof<ID3D12Resource>(),
|
||||
d3D12Resource.GetVoidAddressOf()).Assert();
|
||||
|
||||
return d3D12Resource.Move();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a committed resource for a given 3D texture type.
|
||||
/// </summary>
|
||||
/// <param name="d3D12Device">The <see cref="ID3D12Device"/> instance in use.</param>
|
||||
/// <param name="resourceType">The resource type currently in use.</param>
|
||||
/// <param name="allocationMode">The allocation mode to use for the new resource.</param>
|
||||
/// <param name="dxgiFormat">The <see cref="DXGI_FORMAT"/> value to use.</param>
|
||||
/// <param name="width">The width of the texture resource.</param>
|
||||
/// <param name="height">The height of the texture resource.</param>
|
||||
/// <param name="depth">The depth of the texture resource.</param>
|
||||
/// <param name="isCacheCoherentUMA">Indicates whether or not the current device has a cache coherent UMA architecture.</param>
|
||||
/// <param name="d3D12ResourceStates">The default <see cref="D3D12_RESOURCE_STATES"/> value for the resource.</param>
|
||||
/// <returns>An <see cref="ID3D12Resource"/> reference for the current texture.</returns>
|
||||
public static ComPtr<ID3D12Resource> CreateCommittedResource(
|
||||
this ref ID3D12Device d3D12Device,
|
||||
ResourceType resourceType,
|
||||
AllocationMode allocationMode,
|
||||
DXGI_FORMAT dxgiFormat,
|
||||
uint width,
|
||||
uint height,
|
||||
ushort depth,
|
||||
bool isCacheCoherentUMA,
|
||||
out D3D12_RESOURCE_STATES d3D12ResourceStates)
|
||||
{
|
||||
D3D12_RESOURCE_FLAGS d3D12ResourceFlags;
|
||||
|
||||
(d3D12ResourceFlags, d3D12ResourceStates) = resourceType switch
|
||||
{
|
||||
ResourceType.ReadOnly => (D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COMMON),
|
||||
ResourceType.ReadWrite => (D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
|
||||
_ => ThrowHelper.ThrowArgumentException<(D3D12_RESOURCE_FLAGS, D3D12_RESOURCE_STATES)>()
|
||||
};
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = default;
|
||||
|
||||
D3D12_HEAP_PROPERTIES d3D12HeapProperties;
|
||||
d3D12HeapProperties.CreationNodeMask = 1;
|
||||
d3D12HeapProperties.VisibleNodeMask = 1;
|
||||
|
||||
if (isCacheCoherentUMA)
|
||||
{
|
||||
d3D12HeapProperties.Type = D3D12_HEAP_TYPE_CUSTOM;
|
||||
d3D12HeapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_WRITE_BACK;
|
||||
d3D12HeapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_L0;
|
||||
}
|
||||
else
|
||||
{
|
||||
d3D12HeapProperties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||
d3D12HeapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||
d3D12HeapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||
}
|
||||
|
||||
D3D12_RESOURCE_DESC d3D12ResourceDescription = D3D12_RESOURCE_DESC.Tex3D(dxgiFormat, width, height, depth, mipLevels: 1, flags: d3D12ResourceFlags);
|
||||
|
||||
d3D12Device.CreateCommittedResource(
|
||||
&d3D12HeapProperties,
|
||||
D3D12_HEAP_FLAG_NONE,
|
||||
&d3D12ResourceDescription,
|
||||
d3D12ResourceStates,
|
||||
null,
|
||||
Windows.__uuidof<ID3D12Resource>(),
|
||||
d3D12Resource.GetVoidAddressOf()).Assert();
|
||||
|
||||
return d3D12Resource.Move();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ID3D12InfoQueue"/> for a given device.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Resources;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -55,6 +56,20 @@ public static class ReadBackTexture2DExtensions
|
||||
source.CopyTo(destination, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves a texture to a specified file.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="texture">The texture to save to an image.</param>
|
||||
/// <param name="filename">The filename of the image file to save.</param>
|
||||
public static void Save<T>(this ReadBackTexture2D<T> texture, string filename)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(filename, nameof(filename));
|
||||
|
||||
WICHelper.Instance.SaveTexture(texture.View, filename.AsSpan());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves a texture to a specified file.
|
||||
/// </summary>
|
||||
|
||||
@@ -83,6 +83,7 @@ public static class Texture2DExtensions
|
||||
source.CopyTo(destination.AsSpan(), 0, 0, source.Width, source.Height);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
|
||||
/// </summary>
|
||||
@@ -96,6 +97,7 @@ public static class Texture2DExtensions
|
||||
{
|
||||
source.CopyTo(destination.AsSpan(), x, y);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
|
||||
@@ -126,6 +128,7 @@ public static class Texture2DExtensions
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), 0, 0, source.Width, source.Height);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
|
||||
/// </summary>
|
||||
@@ -140,6 +143,7 @@ public static class Texture2DExtensions
|
||||
{
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), x, y);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target array.
|
||||
@@ -171,6 +175,7 @@ public static class Texture2DExtensions
|
||||
source.CopyTo(destination, 0, 0, source.Width, source.Height);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
|
||||
/// </summary>
|
||||
@@ -187,6 +192,7 @@ public static class Texture2DExtensions
|
||||
|
||||
source.CopyTo(destination, offsetX, offsetY, width, height);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture2D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
|
||||
@@ -323,6 +329,7 @@ public static class Texture2DExtensions
|
||||
destination.CopyFrom(source.AsSpan(), 0, 0, destination.Width, destination.Height);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
|
||||
/// </summary>
|
||||
@@ -336,6 +343,7 @@ public static class Texture2DExtensions
|
||||
{
|
||||
destination.CopyFrom(source.AsSpan(), x, y);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
|
||||
@@ -353,6 +361,7 @@ public static class Texture2DExtensions
|
||||
destination.CopyFrom(source.AsSpan(), destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
|
||||
/// </summary>
|
||||
@@ -367,6 +376,7 @@ public static class Texture2DExtensions
|
||||
{
|
||||
destination.CopyFrom(source.AsSpan(sourceOffset), x, y);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture2D{T}"/> instance.
|
||||
@@ -398,6 +408,7 @@ public static class Texture2DExtensions
|
||||
destination.CopyFrom(source, 0, 0, destination.Width, destination.Height);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture2D{T}"/> instance.
|
||||
/// </summary>
|
||||
@@ -414,6 +425,7 @@ public static class Texture2DExtensions
|
||||
|
||||
destination.CopyFrom(source, offsetX, offsetY, width, height);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture2D{T}"/> instance.
|
||||
@@ -523,6 +535,20 @@ public static class Texture2DExtensions
|
||||
destination.CopyFrom(source, sourceOffsetX, sourceOffsetY, destinationOffsetX, destinationOffsetY, width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves a texture to a specified file.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <param name="texture">The texture to save to an image.</param>
|
||||
/// <param name="filename">The filename of the image file to save.</param>
|
||||
public static void Save<T>(this Texture2D<T> texture, string filename)
|
||||
where T : unmanaged
|
||||
{
|
||||
Guard.IsNotNull(filename, nameof(filename));
|
||||
|
||||
texture.Save(filename.AsSpan());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves a texture to a specified file.
|
||||
/// </summary>
|
||||
|
||||
@@ -95,6 +95,7 @@ public static class Texture3DExtensions
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target array.
|
||||
/// </summary>
|
||||
@@ -110,6 +111,7 @@ public static class Texture3DExtensions
|
||||
{
|
||||
source.CopyTo(destination.AsSpan(destinationOffset), x, y, z);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target array.
|
||||
@@ -142,6 +144,7 @@ public static class Texture3DExtensions
|
||||
source.CopyTo(destination, 0, 0, 0, source.Width, source.Height, source.Depth);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
|
||||
/// </summary>
|
||||
@@ -160,6 +163,7 @@ public static class Texture3DExtensions
|
||||
|
||||
source.CopyTo(destination, offsetX, offsetY, offsetZ, width, height, depth);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reads the contents of the specified range from the current <see cref="Texture3D{T}"/> instance and writes them into a target <see cref="Span{T}"/>.
|
||||
@@ -313,6 +317,7 @@ public static class Texture3DExtensions
|
||||
destination.CopyFrom(source.AsSpan(), 0, 0, 0, destination.Width, destination.Height, destination.Depth);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
|
||||
/// </summary>
|
||||
@@ -327,6 +332,7 @@ public static class Texture3DExtensions
|
||||
{
|
||||
destination.CopyFrom(source.AsSpan(), x, y, z);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
|
||||
@@ -346,6 +352,7 @@ public static class Texture3DExtensions
|
||||
destination.CopyFrom(source.AsSpan(), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
|
||||
/// </summary>
|
||||
@@ -361,6 +368,7 @@ public static class Texture3DExtensions
|
||||
{
|
||||
destination.CopyFrom(source.AsSpan(sourceOffset), x, y, z);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <typeparamref name="T"/> array to a specified area of the current <see cref="Texture3D{T}"/> instance.
|
||||
@@ -394,6 +402,7 @@ public static class Texture3DExtensions
|
||||
destination.CopyFrom(source, 0, 0, 0, destination.Width, destination.Height, destination.Depth);
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture3D{T}"/> instance.
|
||||
/// </summary>
|
||||
@@ -412,6 +421,7 @@ public static class Texture3DExtensions
|
||||
|
||||
destination.CopyFrom(source, offsetX, offsetY, offsetZ, width, height, depth);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Writes the contents of a given <see cref="ReadOnlySpan{T}"/> to a specified area of the current <see cref="Texture3D{T}"/> instance.
|
||||
|
||||
@@ -74,6 +74,7 @@ public sealed unsafe class GraphicsDevice : NativeObject
|
||||
/// </summary>
|
||||
private ulong nextD3D12CopyFenceValue;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12MA_Allocator"/> in use associated to the current device.
|
||||
/// </summary>
|
||||
@@ -83,6 +84,7 @@ public sealed unsafe class GraphicsDevice : NativeObject
|
||||
/// The <see cref="D3D12MA_Pool"/> instance in use, if <see cref="IsCacheCoherentUMA"/> is <see langword="true"/>.
|
||||
/// </summary>
|
||||
private ComPtr<D3D12MA_Pool> pool;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GraphicsDevice"/> instance for the input <see cref="ID3D12Device"/>.
|
||||
@@ -118,12 +120,14 @@ public sealed unsafe class GraphicsDevice : NativeObject
|
||||
|
||||
IsCacheCoherentUMA = d3D12Architecture1Data.CacheCoherentUMA != 0;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocator = d3D12Device->CreateAllocator(dxgiAdapter);
|
||||
|
||||
if (IsCacheCoherentUMA)
|
||||
{
|
||||
this.pool = this.allocator.Get()->CreatePoolForCacheCoherentUMA();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -167,6 +171,7 @@ public sealed unsafe class GraphicsDevice : NativeObject
|
||||
/// </summary>
|
||||
internal ID3D12Device* D3D12Device => this.d3D12Device;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Gets the underlying <see cref="D3D12MA_Allocator"/> wrapped by the current instance.
|
||||
/// </summary>
|
||||
@@ -176,6 +181,7 @@ public sealed unsafe class GraphicsDevice : NativeObject
|
||||
/// Gets the underlying <see cref="D3D12MA_Pool"/> wrapped by the current instance, if any.
|
||||
/// </summary>
|
||||
internal D3D12MA_Pool* Pool => this.pool;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the current device has a cache coherent UMA architecture.
|
||||
@@ -251,8 +257,10 @@ public sealed unsafe class GraphicsDevice : NativeObject
|
||||
/// </summary>
|
||||
internal void RegisterAllocatedResource()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
this.pool.AddRef();
|
||||
this.allocator.AddRef();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -260,8 +268,10 @@ public sealed unsafe class GraphicsDevice : NativeObject
|
||||
/// </summary>
|
||||
internal void UnregisterAllocatedResource()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
this.pool.Release();
|
||||
this.allocator.Release();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID3D12DescriptorHandleAllocator.Rent"/>
|
||||
@@ -365,7 +375,11 @@ public sealed unsafe class GraphicsDevice : NativeObject
|
||||
// Execute the command list
|
||||
d3D12CommandQueue->ExecuteCommandLists(1, commandList.GetD3D12CommandListAddressOf());
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
ulong updatedFenceValue = Interlocked.Increment(ref d3D12FenceValue);
|
||||
#else
|
||||
ulong updatedFenceValue = (ulong)Interlocked.Increment(ref Unsafe.As<ulong, long>(ref d3D12FenceValue));
|
||||
#endif
|
||||
|
||||
// Signal to the target fence with the updated value. Note that incrementing the
|
||||
// target fence value to signal must be done after executing the command list.
|
||||
@@ -394,8 +408,10 @@ public sealed unsafe class GraphicsDevice : NativeObject
|
||||
this.computeCommandListPool.Dispose();
|
||||
this.copyCommandListPool.Dispose();
|
||||
this.shaderResourceViewDescriptorAllocator.Dispose();
|
||||
#if NET6_0_OR_GREATER
|
||||
this.pool.Dispose();
|
||||
this.allocator.Dispose();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_FEATURE;
|
||||
|
||||
namespace ComputeSharp.Graphics.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// A helper <see langword="class"/> exposing some runtime or OS dependent D3D12 features.
|
||||
/// </summary>
|
||||
internal static class D3D12FeatureHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// The currently supported <see cref="D3D12_HEAP_FLAGS.D3D12_HEAP_FLAG_CREATE_NOT_ZEROED"/> flag (or fallback).
|
||||
/// </summary>
|
||||
private static readonly D3D12_HEAP_FLAGS D3D12_HEAP_FLAG_CREATE_NOT_ZEROED = GetD3D12_HEAP_FLAG_CREATE_NOT_ZEROED();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="D3D12_HEAP_FLAGS"/> value for a given <see cref="AllocationMode"/> setting.
|
||||
/// </summary>
|
||||
/// <param name="allocationMode">The allocation mode to use for creating new resources.</param>
|
||||
/// <returns>The <see cref="D3D12_HEAP_FLAGS"/> matching <paramref name="allocationMode"/> that is currently supported</returns>
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static D3D12_HEAP_FLAGS GetD3D12HeapFlags(AllocationMode allocationMode)
|
||||
{
|
||||
if (allocationMode == AllocationMode.Default)
|
||||
{
|
||||
return D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
|
||||
}
|
||||
|
||||
return D3D12_HEAP_FLAGS.D3D12_HEAP_FLAG_NONE;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="D3D12_HEAP_FLAG_CREATE_NOT_ZEROED"/> field.
|
||||
/// </summary>
|
||||
/// <returns>The currently supported <see cref="D3D12_HEAP_FLAGS.D3D12_HEAP_FLAG_CREATE_NOT_ZEROED"/> flag.</returns>
|
||||
private static unsafe D3D12_HEAP_FLAGS GetD3D12_HEAP_FLAG_CREATE_NOT_ZEROED()
|
||||
{
|
||||
lock (DeviceHelper.DevicesCache)
|
||||
{
|
||||
foreach (KeyValuePair<Luid, GraphicsDevice> pair in DeviceHelper.DevicesCache)
|
||||
{
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS7 d3D12Options7;
|
||||
|
||||
int result = pair.Value.D3D12Device->CheckFeatureSupport(
|
||||
D3D12_FEATURE_D3D12_OPTIONS7,
|
||||
&d3D12Options7,
|
||||
(uint)sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS7));
|
||||
|
||||
if (result == S.S_OK)
|
||||
{
|
||||
return D3D12_HEAP_FLAGS.D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return D3D12_HEAP_FLAGS.D3D12_HEAP_FLAG_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,9 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using static TerraFX.Interop.DirectX.D3D12_MESSAGE_SEVERITY;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using Enum = ComputeSharp.NetStandard.System.Enum;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp.Graphics.Helpers;
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
#else
|
||||
using RuntimeHelpers = ComputeSharp.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
#endif
|
||||
|
||||
#pragma warning disable CA1416
|
||||
|
||||
@@ -94,9 +98,15 @@ internal static partial class DeviceHelper
|
||||
|
||||
new Span<IntPtr>(lpVtbl, 30).Clear();
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
lpVtbl[2] = (delegate* unmanaged<IDXGIFactory4As6Backcompat*, uint>)&Release;
|
||||
lpVtbl[27] = (delegate* unmanaged<IDXGIFactory4As6Backcompat*, Guid*, void**, int>)&EnumWarpAdapter;
|
||||
lpVtbl[29] = (delegate* unmanaged<IDXGIFactory4As6Backcompat*, uint, DXGI_GPU_PREFERENCE, Guid*, void**, int>)&EnumAdapterByGpuPreference;
|
||||
#else
|
||||
lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ReleaseWrapper);
|
||||
lpVtbl[27] = (void*)Marshal.GetFunctionPointerForDelegate(EnumWarpAdapterWrapper);
|
||||
lpVtbl[29] = (void*)Marshal.GetFunctionPointerForDelegate(EnumAdapterByGpuPreferenceWrapper);
|
||||
#endif
|
||||
|
||||
return lpVtbl;
|
||||
}
|
||||
@@ -126,8 +136,20 @@ internal static partial class DeviceHelper
|
||||
*dxgiFactory6 = (IDXGIFactory6*)@this;
|
||||
}
|
||||
|
||||
#if !NET6_0_OR_GREATER
|
||||
/// <inheritdoc cref="Release"/>
|
||||
private delegate uint ReleaseDelegate(IDXGIFactory4As6Backcompat* @this);
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="ReleaseDelegate"/> instance wrapping <see cref="Release"/>.
|
||||
/// </summary>
|
||||
private static readonly ReleaseDelegate ReleaseWrapper = Release;
|
||||
#endif
|
||||
|
||||
/// <inheritdoc cref="IUnknown.Release"/>
|
||||
#if NET6_0_OR_GREATER
|
||||
[UnmanagedCallersOnly]
|
||||
#endif
|
||||
public static uint Release(IDXGIFactory4As6Backcompat* @this)
|
||||
{
|
||||
@this->dxgiFactory4->Release();
|
||||
@@ -137,15 +159,39 @@ internal static partial class DeviceHelper
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !NET6_0_OR_GREATER
|
||||
/// <inheritdoc cref="EnumWarpAdapter"/>
|
||||
private delegate int EnumWarpAdapterDelegate(IDXGIFactory4As6Backcompat* @this, Guid* riid, void** ppvAdapter);
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="EnumWarpAdapterDelegate"/> instance wrapping <see cref="EnumWarpAdapter"/>.
|
||||
/// </summary>
|
||||
private static readonly EnumWarpAdapterDelegate EnumWarpAdapterWrapper = EnumWarpAdapter;
|
||||
#endif
|
||||
|
||||
/// <inheritdoc cref="IDXGIFactory6.EnumWarpAdapter(Guid*, void**)"/>
|
||||
#if NET6_0_OR_GREATER
|
||||
[UnmanagedCallersOnly]
|
||||
#endif
|
||||
public static int EnumWarpAdapter(IDXGIFactory4As6Backcompat* @this, Guid* riid, void** ppvAdapter)
|
||||
{
|
||||
return @this->dxgiFactory4->EnumWarpAdapter(riid, ppvAdapter);
|
||||
}
|
||||
|
||||
#if !NET6_0_OR_GREATER
|
||||
/// <inheritdoc cref="EnumAdapterByGpuPreference"/>
|
||||
private delegate int EnumAdapterByGpuPreferenceDelegate(IDXGIFactory4As6Backcompat* @this, uint Adapter, DXGI_GPU_PREFERENCE GpuPreference, Guid* riid, void** ppvAdapter);
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="EnumAdapterByGpuPreferenceDelegate"/> instance wrapping <see cref="EnumAdapterByGpuPreference"/>.
|
||||
/// </summary>
|
||||
private static readonly EnumAdapterByGpuPreferenceDelegate EnumAdapterByGpuPreferenceWrapper = EnumAdapterByGpuPreference;
|
||||
#endif
|
||||
|
||||
/// <inheritdoc cref="IDXGIFactory6.EnumAdapterByGpuPreference(uint, DXGI_GPU_PREFERENCE, Guid*, void**)"/>
|
||||
#if NET6_0_OR_GREATER
|
||||
[UnmanagedCallersOnly]
|
||||
#endif
|
||||
public static int EnumAdapterByGpuPreference(IDXGIFactory4As6Backcompat* @this, uint Adapter, DXGI_GPU_PREFERENCE GpuPreference, Guid* riid, void** ppvAdapter)
|
||||
{
|
||||
return @this->dxgiFactory4->EnumAdapters1(Adapter, (IDXGIAdapter1**)ppvAdapter);
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
using System;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if NET6_0_OR_GREATER
|
||||
using Path = System.IO.Path;
|
||||
#else
|
||||
using Path = ComputeSharp.NetStandard.System.IO.Path;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp.Graphics.Helpers;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.Core.Helpers;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
@@ -11,6 +10,11 @@ using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_FEATURE;
|
||||
using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType;
|
||||
#if NET6_0_OR_GREATER
|
||||
using MemoryMarshal = System.Runtime.InteropServices.MemoryMarshal;
|
||||
#else
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp.Resources;
|
||||
|
||||
@@ -21,10 +25,12 @@ namespace ComputeSharp.Resources;
|
||||
public unsafe abstract class Buffer<T> : NativeObject
|
||||
where T : unmanaged
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12MA_Allocation"/> instance used to retrieve <see cref="d3D12Resource"/>.
|
||||
/// </summary>
|
||||
private ComPtr<D3D12MA_Allocation> allocation;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12Resource"/> instance currently mapped.
|
||||
@@ -81,8 +87,12 @@ public unsafe abstract class Buffer<T> : NativeObject
|
||||
GraphicsDevice = device;
|
||||
Length = length;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation = device.Allocator->CreateResource(device.Pool, resourceType, allocationMode, (ulong)effectiveSizeInBytes);
|
||||
this.d3D12Resource = new ComPtr<ID3D12Resource>(this.allocation.Get()->GetResource());
|
||||
#else
|
||||
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, allocationMode, (ulong)effectiveSizeInBytes, device.IsCacheCoherentUMA);
|
||||
#endif
|
||||
|
||||
device.RegisterAllocatedResource();
|
||||
device.RentShaderResourceViewDescriptorHandles(out D3D12CpuDescriptorHandle, out D3D12GpuDescriptorHandle);
|
||||
@@ -181,7 +191,9 @@ public unsafe abstract class Buffer<T> : NativeObject
|
||||
protected override void OnDispose()
|
||||
{
|
||||
this.d3D12Resource.Dispose();
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation.Dispose();
|
||||
#endif
|
||||
|
||||
if (GraphicsDevice is GraphicsDevice device)
|
||||
{
|
||||
|
||||
@@ -61,15 +61,31 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
nint byteOffset = (nint)sourceOffset * sizeof(T);
|
||||
nint byteLength = count * sizeof(T);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using ComPtr<D3D12MA_Allocation> allocation = GraphicsDevice.Allocator->CreateResource(null, ResourceType.ReadBack, AllocationMode.Default, (ulong)byteLength);
|
||||
#else
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(
|
||||
ResourceType.ReadBack,
|
||||
AllocationMode.Default,
|
||||
(ulong)byteLength,
|
||||
GraphicsDevice.IsCacheCoherentUMA);
|
||||
#endif
|
||||
|
||||
using (CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY))
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyBufferRegion(allocation.Get()->GetResource(), 0, D3D12Resource, (ulong)byteOffset, (ulong)byteLength);
|
||||
#else
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyBufferRegion(d3D12Resource.Get(), 0, D3D12Resource, (ulong)byteOffset, (ulong)byteLength);
|
||||
#endif
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using ID3D12ResourceMap resource = allocation.Get()->GetResource()->Map();
|
||||
#else
|
||||
using ID3D12ResourceMap resource = d3D12Resource.Get()->Map();
|
||||
#endif
|
||||
|
||||
fixed (void* destinationPointer = &destination)
|
||||
{
|
||||
@@ -204,9 +220,21 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
nint byteOffset = (nint)offset * sizeof(T);
|
||||
nint byteLength = length * sizeof(T);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using ComPtr<D3D12MA_Allocation> allocation = GraphicsDevice.Allocator->CreateResource(null, ResourceType.Upload, AllocationMode.Default, (ulong)byteLength);
|
||||
#else
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(
|
||||
ResourceType.Upload,
|
||||
AllocationMode.Default,
|
||||
(ulong)byteLength,
|
||||
GraphicsDevice.IsCacheCoherentUMA);
|
||||
#endif
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using (ID3D12ResourceMap resource = allocation.Get()->GetResource()->Map())
|
||||
#else
|
||||
using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map())
|
||||
#endif
|
||||
fixed (void* sourcePointer = &source)
|
||||
{
|
||||
MemoryHelper.Copy<T>(
|
||||
@@ -221,7 +249,11 @@ public abstract class StructuredBuffer<T> : Buffer<T>
|
||||
|
||||
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyBufferRegion(D3D12Resource, (ulong)byteOffset, allocation.Get()->GetResource(), 0, (ulong)byteLength);
|
||||
#else
|
||||
copyCommandList.D3D12GraphicsCommandList->CopyBufferRegion(D3D12Resource, (ulong)byteOffset, d3D12Resource.Get(), 0, (ulong)byteLength);
|
||||
#endif
|
||||
copyCommandList.ExecuteAndWaitForCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,12 @@ namespace ComputeSharp.Resources;
|
||||
public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper.IGraphicsResource
|
||||
where T : unmanaged
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12MA_Allocation"/> instance used to retrieve <see cref="d3D12Resource"/>.
|
||||
/// </summary>
|
||||
private ComPtr<D3D12MA_Allocation> allocation;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12Resource"/> instance currently mapped.
|
||||
@@ -84,6 +86,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
|
||||
GraphicsDevice = device;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation = device.Allocator->CreateResource(
|
||||
device.Pool,
|
||||
resourceType,
|
||||
@@ -94,6 +97,16 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
out this.d3D12ResourceState);
|
||||
|
||||
this.d3D12Resource = new ComPtr<ID3D12Resource>(this.allocation.Get()->GetResource());
|
||||
#else
|
||||
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(
|
||||
resourceType,
|
||||
allocationMode,
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
device.IsCacheCoherentUMA,
|
||||
out this.d3D12ResourceState);
|
||||
#endif
|
||||
|
||||
this.d3D12CommandListType = this.d3D12ResourceState == D3D12_RESOURCE_STATE_COMMON
|
||||
? D3D12_COMMAND_LIST_TYPE_COPY
|
||||
@@ -174,6 +187,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using ComPtr<D3D12MA_Allocation> allocation = GraphicsDevice.Allocator->CreateResource(
|
||||
GraphicsDevice.Pool,
|
||||
ResourceType.ReadBack,
|
||||
@@ -181,6 +195,13 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
totalSizeInBytes);
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = new(allocation.Get()->GetResource());
|
||||
#else
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(
|
||||
ResourceType.ReadBack,
|
||||
AllocationMode.Default,
|
||||
totalSizeInBytes,
|
||||
GraphicsDevice.IsCacheCoherentUMA);
|
||||
#endif
|
||||
|
||||
using (CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType))
|
||||
{
|
||||
@@ -387,6 +408,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using ComPtr<D3D12MA_Allocation> allocation = GraphicsDevice.Allocator->CreateResource(
|
||||
GraphicsDevice.Pool,
|
||||
ResourceType.Upload,
|
||||
@@ -394,6 +416,13 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
totalSizeInBytes);
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = new(allocation.Get()->GetResource());
|
||||
#else
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(
|
||||
ResourceType.Upload,
|
||||
AllocationMode.Default,
|
||||
totalSizeInBytes,
|
||||
GraphicsDevice.IsCacheCoherentUMA);
|
||||
#endif
|
||||
|
||||
using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map())
|
||||
fixed (void* sourcePointer = &source)
|
||||
@@ -503,7 +532,9 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
|
||||
protected override void OnDispose()
|
||||
{
|
||||
this.d3D12Resource.Dispose();
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation.Dispose();
|
||||
#endif
|
||||
|
||||
if (GraphicsDevice is GraphicsDevice device)
|
||||
{
|
||||
|
||||
@@ -26,10 +26,12 @@ namespace ComputeSharp.Resources;
|
||||
public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper.IGraphicsResource
|
||||
where T : unmanaged
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12MA_Allocation"/> instance used to retrieve <see cref="d3D12Resource"/>.
|
||||
/// </summary>
|
||||
private ComPtr<D3D12MA_Allocation> allocation;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12Resource"/> instance currently mapped.
|
||||
@@ -86,6 +88,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
|
||||
GraphicsDevice = device;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation = device.Allocator->CreateResource(
|
||||
device.Pool,
|
||||
resourceType,
|
||||
@@ -97,6 +100,17 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
out this.d3D12ResourceState);
|
||||
|
||||
this.d3D12Resource = new ComPtr<ID3D12Resource>(this.allocation.Get()->GetResource());
|
||||
#else
|
||||
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(
|
||||
resourceType,
|
||||
allocationMode,
|
||||
DXGIFormatHelper.GetForType<T>(),
|
||||
(uint)width,
|
||||
(uint)height,
|
||||
(ushort)depth,
|
||||
device.IsCacheCoherentUMA,
|
||||
out this.d3D12ResourceState);
|
||||
#endif
|
||||
|
||||
this.d3D12CommandListType = this.d3D12ResourceState == D3D12_RESOURCE_STATE_COMMON
|
||||
? D3D12_COMMAND_LIST_TYPE_COPY
|
||||
@@ -189,6 +203,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using ComPtr<D3D12MA_Allocation> allocation = GraphicsDevice.Allocator->CreateResource(
|
||||
GraphicsDevice.Pool,
|
||||
ResourceType.ReadBack,
|
||||
@@ -196,6 +211,13 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
totalSizeInBytes);
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = new(allocation.Get()->GetResource());
|
||||
#else
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(
|
||||
ResourceType.ReadBack,
|
||||
AllocationMode.Default,
|
||||
totalSizeInBytes,
|
||||
GraphicsDevice.IsCacheCoherentUMA);
|
||||
#endif
|
||||
|
||||
using (CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType))
|
||||
{
|
||||
@@ -428,6 +450,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
out ulong rowSizeInBytes,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using ComPtr<D3D12MA_Allocation> allocation = GraphicsDevice.Allocator->CreateResource(
|
||||
GraphicsDevice.Pool,
|
||||
ResourceType.Upload,
|
||||
@@ -435,6 +458,13 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
totalSizeInBytes);
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = new(allocation.Get()->GetResource());
|
||||
#else
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = GraphicsDevice.D3D12Device->CreateCommittedResource(
|
||||
ResourceType.Upload,
|
||||
AllocationMode.Default,
|
||||
totalSizeInBytes,
|
||||
GraphicsDevice.IsCacheCoherentUMA);
|
||||
#endif
|
||||
|
||||
using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map())
|
||||
fixed (void* sourcePointer = &source)
|
||||
@@ -555,7 +585,9 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
|
||||
protected override void OnDispose()
|
||||
{
|
||||
this.d3D12Resource.Dispose();
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation.Dispose();
|
||||
#endif
|
||||
|
||||
if (GraphicsDevice is GraphicsDevice device)
|
||||
{
|
||||
|
||||
@@ -18,10 +18,12 @@ namespace ComputeSharp.Resources;
|
||||
public abstract unsafe class TransferBuffer<T> : NativeObject, IMemoryOwner<T>
|
||||
where T : unmanaged
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12MA_Allocation"/> instance used to retrieve <see cref="d3D12Resource"/>.
|
||||
/// </summary>
|
||||
private ComPtr<D3D12MA_Allocation> allocation;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12Resource"/> instance currently mapped.
|
||||
@@ -52,8 +54,12 @@ public abstract unsafe class TransferBuffer<T> : NativeObject, IMemoryOwner<T>
|
||||
|
||||
ulong sizeInBytes = (uint)length * (uint)sizeof(T);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation = device.Allocator->CreateResource(device.Pool, resourceType, allocationMode, sizeInBytes);
|
||||
this.d3D12Resource = new ComPtr<ID3D12Resource>(this.allocation.Get()->GetResource());
|
||||
#else
|
||||
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, allocationMode, sizeInBytes, device.IsCacheCoherentUMA);
|
||||
#endif
|
||||
|
||||
device.RegisterAllocatedResource();
|
||||
|
||||
@@ -110,7 +116,9 @@ public abstract unsafe class TransferBuffer<T> : NativeObject, IMemoryOwner<T>
|
||||
protected override void OnDispose()
|
||||
{
|
||||
this.d3D12Resource.Dispose();
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation.Dispose();
|
||||
#endif
|
||||
|
||||
if (GraphicsDevice is GraphicsDevice device)
|
||||
{
|
||||
|
||||
@@ -18,10 +18,12 @@ namespace ComputeSharp.Resources;
|
||||
public unsafe abstract class TransferTexture2D<T> : NativeObject
|
||||
where T : unmanaged
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12MA_Allocation"/> instance used to retrieve <see cref="d3D12Resource"/>.
|
||||
/// </summary>
|
||||
private ComPtr<D3D12MA_Allocation> allocation;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12Resource"/> instance currently mapped.
|
||||
@@ -68,8 +70,12 @@ public unsafe abstract class TransferTexture2D<T> : NativeObject
|
||||
out _,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation = device.Allocator->CreateResource(device.Pool, resourceType, allocationMode, totalSizeInBytes);
|
||||
this.d3D12Resource = new ComPtr<ID3D12Resource>(this.allocation.Get()->GetResource());
|
||||
#else
|
||||
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, allocationMode, totalSizeInBytes, device.IsCacheCoherentUMA);
|
||||
#endif
|
||||
|
||||
device.RegisterAllocatedResource();
|
||||
|
||||
@@ -119,7 +125,9 @@ public unsafe abstract class TransferTexture2D<T> : NativeObject
|
||||
protected override void OnDispose()
|
||||
{
|
||||
this.d3D12Resource.Dispose();
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation.Dispose();
|
||||
#endif
|
||||
|
||||
if (GraphicsDevice is GraphicsDevice device)
|
||||
{
|
||||
|
||||
@@ -18,10 +18,12 @@ namespace ComputeSharp.Resources;
|
||||
public unsafe abstract class TransferTexture3D<T> : NativeObject
|
||||
where T : unmanaged
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12MA_Allocation"/> instance used to retrieve <see cref="d3D12Resource"/>.
|
||||
/// </summary>
|
||||
private ComPtr<D3D12MA_Allocation> allocation;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12Resource"/> instance currently mapped.
|
||||
@@ -71,8 +73,12 @@ public unsafe abstract class TransferTexture3D<T> : NativeObject
|
||||
out _,
|
||||
out ulong totalSizeInBytes);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation = device.Allocator->CreateResource(device.Pool, resourceType, allocationMode, totalSizeInBytes);
|
||||
this.d3D12Resource = new ComPtr<ID3D12Resource>(this.allocation.Get()->GetResource());
|
||||
#else
|
||||
this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, allocationMode, totalSizeInBytes, device.IsCacheCoherentUMA);
|
||||
#endif
|
||||
|
||||
device.RegisterAllocatedResource();
|
||||
|
||||
@@ -127,7 +133,9 @@ public unsafe abstract class TransferTexture3D<T> : NativeObject
|
||||
protected override void OnDispose()
|
||||
{
|
||||
this.d3D12Resource.Dispose();
|
||||
#if NET6_0_OR_GREATER
|
||||
this.allocation.Dispose();
|
||||
#endif
|
||||
|
||||
if (GraphicsDevice is GraphicsDevice device)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
#if NET6_0_OR_GREATER
|
||||
using GC = System.GC;
|
||||
#else
|
||||
using GC = ComputeSharp.NetStandard.System.GC;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp.Resources.Debug;
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
#if NET6_0_OR_GREATER
|
||||
using GC = System.GC;
|
||||
#else
|
||||
using GC = ComputeSharp.NetStandard.System.GC;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp.Resources.Debug;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ internal readonly unsafe struct ShaderDispatchMetadataLoader : IDispatchMetadata
|
||||
*(ComPtr<ID3D12RootSignature>*)p = this.d3D12Device->CreateRootSignature(
|
||||
MemoryMarshal.Read<int>(serializedMetadata),
|
||||
MemoryMarshal.Cast<ResourceDescriptor, D3D12_DESCRIPTOR_RANGE1>(resourceDescriptors),
|
||||
MemoryMarshal.Read<bool>(serializedMetadata[4..]));
|
||||
MemoryMarshal.Read<bool>(serializedMetadata.Slice(4)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
#if NET6_0_OR_GREATER
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
@@ -67,3 +69,5 @@ internal sealed unsafe partial class ShaderCompiler
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -67,7 +67,11 @@ public ref struct ArrayPoolStringBuilder
|
||||
{
|
||||
EnsureCapacity(value.Length);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
value.CopyTo(this.array.AsSpan(this.index));
|
||||
#else
|
||||
value.AsSpan().CopyTo(this.array.AsSpan(this.index));
|
||||
#endif
|
||||
|
||||
this.index += value.Length;
|
||||
}
|
||||
@@ -78,6 +82,7 @@ public ref struct ArrayPoolStringBuilder
|
||||
/// <param name="value">The input value to write.</param>
|
||||
public void Append(int value)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
int charsWritten;
|
||||
|
||||
while (!value.TryFormat(this.array.AsSpan(this.index), out charsWritten))
|
||||
@@ -86,6 +91,9 @@ public ref struct ArrayPoolStringBuilder
|
||||
}
|
||||
|
||||
this.index += charsWritten;
|
||||
#else
|
||||
Append(value.ToString());
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from winrt/wrl/client.h in the Windows SDK for Windows 10.0.20348.0
|
||||
// Original source is Copyright © Microsoft. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using static TerraFX.Interop.Windows.S;
|
||||
using static TerraFX.Interop.Windows.Windows;
|
||||
|
||||
namespace TerraFX.Interop.Windows
|
||||
{
|
||||
/// <summary>A type that allows working with pointers to COM objects more securely.</summary>
|
||||
/// <typeparam name="T">The type to wrap in the current <see cref="ComPtr{T}"/> instance.</typeparam>
|
||||
/// <remarks>While this type is not marked as <see langword="ref"/> so that it can also be used in fields, make sure to keep the reference counts properly tracked if you do store <see cref="ComPtr{T}"/> instances on the heap.</remarks>
|
||||
internal unsafe struct ComPtr<T> : IDisposable
|
||||
where T : unmanaged, IUnknown.Interface
|
||||
{
|
||||
/// <summary>The raw pointer to a COM object, if existing.</summary>
|
||||
private T* ptr_;
|
||||
|
||||
/// <summary>Creates a new <see cref="ComPtr{T}"/> instance from a raw pointer and increments the ref count.</summary>
|
||||
/// <param name="other">The raw pointer to wrap.</param>
|
||||
public ComPtr(T* other)
|
||||
{
|
||||
ptr_ = other;
|
||||
InternalAddRef();
|
||||
}
|
||||
|
||||
/// <summary>Creates a new <see cref="ComPtr{T}"/> instance from a second one and increments the ref count.</summary>
|
||||
/// <param name="other">The other <see cref="ComPtr{T}"/> instance to copy.</param>
|
||||
public ComPtr(ComPtr<T> other)
|
||||
{
|
||||
ptr_ = other.ptr_;
|
||||
InternalAddRef();
|
||||
}
|
||||
|
||||
/// <summary>Converts a raw pointer to a new <see cref="ComPtr{T}"/> instance and increments the ref count.</summary>
|
||||
/// <param name="other">The raw pointer to wrap.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ComPtr<T>(T* other)
|
||||
=> new ComPtr<T>(other);
|
||||
|
||||
/// <summary>Unwraps a <see cref="ComPtr{T}"/> instance and returns the internal raw pointer.</summary>
|
||||
/// <param name="other">The <see cref="ComPtr{T}"/> instance to unwrap.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator T*(ComPtr<T> other)
|
||||
=> other.Get();
|
||||
|
||||
/// <summary>Converts the current object reference to type <typeparamref name="U"/> and assigns that to a target <see cref="ComPtr{T}"/> value.</summary>
|
||||
/// <typeparam name="U">The interface type to use to try casting the current COM object.</typeparam>
|
||||
/// <param name="p">A raw pointer to the target <see cref="ComPtr{T}"/> value to write to.</param>
|
||||
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns>
|
||||
/// <remarks>This method will automatically release the target COM object pointed to by <paramref name="p"/>, if any.</remarks>
|
||||
public readonly HRESULT As<U>(ComPtr<U>* p)
|
||||
where U : unmanaged, IUnknown.Interface
|
||||
{
|
||||
return ptr_->QueryInterface(__uuidof<U>(), (void**)p->ReleaseAndGetAddressOf());
|
||||
}
|
||||
|
||||
/// <summary>Converts the current object reference to type <typeparamref name="U"/> and assigns that to a target <see cref="ComPtr{T}"/> value.</summary>
|
||||
/// <typeparam name="U">The interface type to use to try casting the current COM object.</typeparam>
|
||||
/// <param name="other">A reference to the target <see cref="ComPtr{T}"/> value to write to.</param>
|
||||
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns>
|
||||
/// <remarks>This method will automatically release the target COM object pointed to by <paramref name="other"/>, if any.</remarks>
|
||||
public readonly HRESULT As<U>(ref ComPtr<U> other)
|
||||
where U : unmanaged, IUnknown.Interface
|
||||
{
|
||||
U* ptr;
|
||||
HRESULT result = ptr_->QueryInterface(__uuidof<U>(), (void**)&ptr);
|
||||
|
||||
other.Attach(ptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Converts the current object reference to a type indicated by the given IID and assigns that to a target <see cref="ComPtr{T}"/> value.</summary>
|
||||
/// <param name="riid">The IID indicating the interface type to convert the COM object reference to.</param>
|
||||
/// <param name="other">A raw pointer to the target <see cref="ComPtr{T}"/> value to write to.</param>
|
||||
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target IID.</returns>
|
||||
/// <remarks>This method will automatically release the target COM object pointed to by <paramref name="other"/>, if any.</remarks>
|
||||
public readonly HRESULT AsIID(Guid* riid, ComPtr<IUnknown>* other)
|
||||
{
|
||||
return ptr_->QueryInterface(riid, (void**)other->ReleaseAndGetAddressOf());
|
||||
}
|
||||
|
||||
/// <summary>Converts the current object reference to a type indicated by the given IID and assigns that to a target <see cref="ComPtr{T}"/> value.</summary>
|
||||
/// <param name="riid">The IID indicating the interface type to convert the COM object reference to.</param>
|
||||
/// <param name="other">A reference to the target <see cref="ComPtr{T}"/> value to write to.</param>
|
||||
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target IID.</returns>
|
||||
/// <remarks>This method will automatically release the target COM object pointed to by <paramref name="other"/>, if any.</remarks>
|
||||
public readonly HRESULT AsIID(Guid* riid, ref ComPtr<IUnknown> other)
|
||||
{
|
||||
IUnknown* ptr;
|
||||
HRESULT result = ptr_->QueryInterface(riid, (void**)&ptr);
|
||||
|
||||
other.Attach(ptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Releases the current COM object, if any, and replaces the internal pointer with an input raw pointer.</summary>
|
||||
/// <param name="other">The input raw pointer to wrap.</param>
|
||||
/// <remarks>This method will release the current raw pointer, if any, but it will not increment the references for <paramref name="other"/>.</remarks>
|
||||
public void Attach(T* other)
|
||||
{
|
||||
if (ptr_ != null)
|
||||
{
|
||||
var @ref = ptr_->Release();
|
||||
Debug.Assert((@ref != 0) || (ptr_ != other));
|
||||
}
|
||||
ptr_ = other;
|
||||
}
|
||||
|
||||
/// <summary>Returns the raw pointer wrapped by the current instance, and resets the current <see cref="ComPtr{T}"/> value.</summary>
|
||||
/// <returns>The raw pointer wrapped by the current <see cref="ComPtr{T}"/> value.</returns>
|
||||
/// <remarks>This method will not change the reference count for the COM object in use.</remarks>
|
||||
public T* Detach()
|
||||
{
|
||||
T* ptr = ptr_;
|
||||
ptr_ = null;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/// <summary>Increments the reference count for the current COM object, if any, and copies its address to a target raw pointer.</summary>
|
||||
/// <param name="ptr">The target raw pointer to copy the address of the current COM object to.</param>
|
||||
/// <returns>This method always returns <see cref="S_OK"/>.</returns>
|
||||
public readonly HRESULT CopyTo(T** ptr)
|
||||
{
|
||||
InternalAddRef();
|
||||
*ptr = ptr_;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/// <summary>Increments the reference count for the current COM object, if any, and copies its address to a target <see cref="ComPtr{T}"/>.</summary>
|
||||
/// <param name="p">The target raw pointer to copy the address of the current COM object to.</param>
|
||||
/// <returns>This method always returns <see cref="S_OK"/>.</returns>
|
||||
public readonly HRESULT CopyTo(ComPtr<T>* p)
|
||||
{
|
||||
InternalAddRef();
|
||||
*p->ReleaseAndGetAddressOf() = ptr_;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/// <summary>Increments the reference count for the current COM object, if any, and copies its address to a target <see cref="ComPtr{T}"/>.</summary>
|
||||
/// <param name="other">The target reference to copy the address of the current COM object to.</param>
|
||||
/// <returns>This method always returns <see cref="S_OK"/>.</returns>
|
||||
public readonly HRESULT CopyTo(ref ComPtr<T> other)
|
||||
{
|
||||
InternalAddRef();
|
||||
other.Attach(ptr_);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/// <summary>Converts the current COM object reference to a given interface type and assigns that to a target raw pointer.</summary>
|
||||
/// <param name="ptr">The target raw pointer to copy the address of the current COM object to.</param>
|
||||
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns>
|
||||
public readonly HRESULT CopyTo<U>(U** ptr)
|
||||
where U : unmanaged, IUnknown.Interface
|
||||
{
|
||||
return ptr_->QueryInterface(__uuidof<U>(), (void**)ptr);
|
||||
}
|
||||
|
||||
/// <summary>Converts the current COM object reference to a given interface type and assigns that to a target <see cref="ComPtr{T}"/>.</summary>
|
||||
/// <param name="p">The target raw pointer to copy the address of the current COM object to.</param>
|
||||
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns>
|
||||
public readonly HRESULT CopyTo<U>(ComPtr<U>* p)
|
||||
where U : unmanaged, IUnknown.Interface
|
||||
{
|
||||
return ptr_->QueryInterface(__uuidof<U>(), (void**)p->ReleaseAndGetAddressOf());
|
||||
}
|
||||
|
||||
/// <summary>Converts the current COM object reference to a given interface type and assigns that to a target <see cref="ComPtr{T}"/>.</summary>
|
||||
/// <param name="other">The target reference to copy the address of the current COM object to.</param>
|
||||
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns>
|
||||
public readonly HRESULT CopyTo<U>(ref ComPtr<U> other)
|
||||
where U : unmanaged, IUnknown.Interface
|
||||
{
|
||||
U* ptr;
|
||||
HRESULT result = ptr_->QueryInterface(__uuidof<U>(), (void**)&ptr);
|
||||
|
||||
other.Attach(ptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Converts the current object reference to a type indicated by the given IID and assigns that to a target address.</summary>
|
||||
/// <param name="riid">The IID indicating the interface type to convert the COM object reference to.</param>
|
||||
/// <param name="ptr">The target raw pointer to copy the address of the current COM object to.</param>
|
||||
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target IID.</returns>
|
||||
public readonly HRESULT CopyTo(Guid* riid, void** ptr)
|
||||
{
|
||||
return ptr_->QueryInterface(riid, ptr);
|
||||
}
|
||||
|
||||
/// <summary>Converts the current object reference to a type indicated by the given IID and assigns that to a target <see cref="ComPtr{T}"/> value.</summary>
|
||||
/// <param name="riid">The IID indicating the interface type to convert the COM object reference to.</param>
|
||||
/// <param name="p">The target raw pointer to copy the address of the current COM object to.</param>
|
||||
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target IID.</returns>
|
||||
public readonly HRESULT CopyTo(Guid* riid, ComPtr<IUnknown>* p)
|
||||
{
|
||||
return ptr_->QueryInterface(riid, (void**)p->ReleaseAndGetAddressOf());
|
||||
}
|
||||
|
||||
/// <summary>Converts the current object reference to a type indicated by the given IID and assigns that to a target <see cref="ComPtr{T}"/> value.</summary>
|
||||
/// <param name="riid">The IID indicating the interface type to convert the COM object reference to.</param>
|
||||
/// <param name="other">The target reference to copy the address of the current COM object to.</param>
|
||||
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target IID.</returns>
|
||||
public readonly HRESULT CopyTo(Guid* riid, ref ComPtr<IUnknown> other)
|
||||
{
|
||||
IUnknown* ptr;
|
||||
HRESULT result = ptr_->QueryInterface(riid, (void**)&ptr);
|
||||
|
||||
other.Attach(ptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose()
|
||||
{
|
||||
T* pointer = ptr_;
|
||||
|
||||
if (pointer != null)
|
||||
{
|
||||
ptr_ = null;
|
||||
_ = pointer->Release();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets the currently wrapped raw pointer to a COM object.</summary>
|
||||
/// <returns>The raw pointer wrapped by the current <see cref="ComPtr{T}"/> instance.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly T* Get()
|
||||
{
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
/// <summary>Gets the address of the current <see cref="ComPtr{T}"/> instance as a raw <typeparamref name="T"/> double pointer. This method is only valid when the current <see cref="ComPtr{T}"/> instance is on the stack or pinned.
|
||||
/// </summary>
|
||||
/// <returns>The raw pointer to the current <see cref="ComPtr{T}"/> instance.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly T** GetAddressOf()
|
||||
{
|
||||
return (T**)Unsafe.AsPointer(ref Unsafe.AsRef(in this));
|
||||
}
|
||||
|
||||
/// <summary>Gets the address of the current <see cref="ComPtr{T}"/> instance as a raw <typeparamref name="T"/> double pointer.</summary>
|
||||
/// <returns>The raw pointer to the current <see cref="ComPtr{T}"/> instance.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public readonly ref T* GetPinnableReference()
|
||||
{
|
||||
fixed (T** ptr = &ptr_)
|
||||
{
|
||||
return ref *ptr;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Releases the current COM object in use and gets the address of the <see cref="ComPtr{T}"/> instance as a raw <typeparamref name="T"/> double pointer. This method is only valid when the current <see cref="ComPtr{T}"/> instance is on the stack or pinned.</summary>
|
||||
/// <returns>The raw pointer to the current <see cref="ComPtr{T}"/> instance.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public T** ReleaseAndGetAddressOf()
|
||||
{
|
||||
_ = InternalRelease();
|
||||
return GetAddressOf();
|
||||
}
|
||||
|
||||
/// <summary>Resets the current instance by decrementing the reference count for the target COM object and setting the internal raw pointer to <see langword="null"/>.</summary>
|
||||
/// <returns>The updated reference count for the COM object that was in use, if any.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint Reset()
|
||||
{
|
||||
return InternalRelease();
|
||||
}
|
||||
|
||||
/// <summary>Swaps the current COM object reference with that of a given <see cref="ComPtr{T}"/> instance.</summary>
|
||||
/// <param name="r">The target <see cref="ComPtr{T}"/> instance to swap with the current one.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Swap(ComPtr<T>* r)
|
||||
{
|
||||
T* tmp = ptr_;
|
||||
ptr_ = r->ptr_;
|
||||
r->ptr_ = tmp;
|
||||
}
|
||||
|
||||
/// <summary>Swaps the current COM object reference with that of a given <see cref="ComPtr{T}"/> instance.</summary>
|
||||
/// <param name="other">The target <see cref="ComPtr{T}"/> instance to swap with the current one.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Swap(ref ComPtr<T> other)
|
||||
{
|
||||
T* tmp = ptr_;
|
||||
ptr_ = other.ptr_;
|
||||
other.ptr_ = tmp;
|
||||
}
|
||||
|
||||
// Increments the reference count for the current COM object, if any
|
||||
private readonly void InternalAddRef()
|
||||
{
|
||||
T* temp = ptr_;
|
||||
|
||||
if (temp != null)
|
||||
{
|
||||
_ = temp->AddRef();
|
||||
}
|
||||
}
|
||||
|
||||
// Decrements the reference count for the current COM object, if any
|
||||
private uint InternalRelease()
|
||||
{
|
||||
uint @ref = 0;
|
||||
T* temp = ptr_;
|
||||
|
||||
if (temp != null)
|
||||
{
|
||||
ptr_ = null;
|
||||
@ref = temp->Release();
|
||||
}
|
||||
|
||||
return @ref;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
using System;
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal partial struct D3D12_BOX : IEquatable<D3D12_BOX>
|
||||
{
|
||||
public D3D12_BOX([NativeTypeName("LONG")] int Left, [NativeTypeName("LONG")] int Right)
|
||||
{
|
||||
left = (uint)Left;
|
||||
top = 0;
|
||||
front = 0;
|
||||
right = (uint)Right;
|
||||
bottom = 1;
|
||||
back = 1;
|
||||
}
|
||||
|
||||
public D3D12_BOX([NativeTypeName("LONG")] int Left, [NativeTypeName("LONG")] int Top, [NativeTypeName("LONG")] int Right, [NativeTypeName("LONG")] int Bottom)
|
||||
{
|
||||
left = (uint)Left;
|
||||
top = (uint)Top;
|
||||
front = 0;
|
||||
right = (uint)Right;
|
||||
bottom = (uint)Bottom;
|
||||
back = 1;
|
||||
}
|
||||
|
||||
public D3D12_BOX([NativeTypeName("LONG")] int Left, [NativeTypeName("LONG")] int Top, [NativeTypeName("LONG")] int Front, [NativeTypeName("LONG")] int Right, [NativeTypeName("LONG")] int Bottom, [NativeTypeName("LONG")] int Back)
|
||||
{
|
||||
left = (uint)Left;
|
||||
top = (uint)Top;
|
||||
front = (uint)Front;
|
||||
right = (uint)Right;
|
||||
bottom = (uint)Bottom;
|
||||
back = (uint)Back;
|
||||
}
|
||||
|
||||
public static bool operator ==([NativeTypeName("const D3D12_BOX &")] in D3D12_BOX l, [NativeTypeName("const D3D12_BOX &")] in D3D12_BOX r)
|
||||
{
|
||||
return l.left == r.left && l.top == r.top && l.front == r.front && l.right == r.right && l.bottom == r.bottom && l.back == r.back;
|
||||
}
|
||||
|
||||
public static bool operator !=([NativeTypeName("const D3D12_BOX &")] in D3D12_BOX l, [NativeTypeName("const D3D12_BOX &")] in D3D12_BOX r)
|
||||
{
|
||||
return !(l == r);
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj) => (obj is D3D12_BOX other) && Equals(other);
|
||||
|
||||
public bool Equals(D3D12_BOX other) => this == other;
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(left, top, front, right, bottom, back);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
using System;
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal unsafe partial struct D3D12_CPU_DESCRIPTOR_HANDLE : IEquatable<D3D12_CPU_DESCRIPTOR_HANDLE>
|
||||
{
|
||||
public static D3D12_CPU_DESCRIPTOR_HANDLE DEFAULT => default;
|
||||
|
||||
public D3D12_CPU_DESCRIPTOR_HANDLE([NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE &")] in D3D12_CPU_DESCRIPTOR_HANDLE other, int offsetScaledByIncrementSize)
|
||||
{
|
||||
InitOffsetted(out this, other, offsetScaledByIncrementSize);
|
||||
}
|
||||
|
||||
public D3D12_CPU_DESCRIPTOR_HANDLE([NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE &")] in D3D12_CPU_DESCRIPTOR_HANDLE other, int offsetInDescriptors, uint descriptorIncrementSize)
|
||||
{
|
||||
InitOffsetted(out this, other, offsetInDescriptors, descriptorIncrementSize);
|
||||
}
|
||||
|
||||
public D3D12_CPU_DESCRIPTOR_HANDLE Offset(int offsetInDescriptors, uint descriptorIncrementSize)
|
||||
{
|
||||
ptr = unchecked((nuint)((long)ptr + ((long)offsetInDescriptors * (long)descriptorIncrementSize)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public D3D12_CPU_DESCRIPTOR_HANDLE Offset(int offsetScaledByIncrementSize)
|
||||
{
|
||||
ptr = unchecked((nuint)((long)ptr + (long)offsetScaledByIncrementSize));
|
||||
return this;
|
||||
}
|
||||
|
||||
public static bool operator ==([NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE &")] in D3D12_CPU_DESCRIPTOR_HANDLE l, [NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE &")] in D3D12_CPU_DESCRIPTOR_HANDLE r)
|
||||
=> (l.ptr == r.ptr);
|
||||
|
||||
public static bool operator !=([NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE &")] in D3D12_CPU_DESCRIPTOR_HANDLE l, [NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE &")] in D3D12_CPU_DESCRIPTOR_HANDLE r)
|
||||
=> (l.ptr != r.ptr);
|
||||
|
||||
public void InitOffsetted([NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE &")] in D3D12_CPU_DESCRIPTOR_HANDLE @base, int offsetScaledByIncrementSize)
|
||||
{
|
||||
InitOffsetted(out this, @base, offsetScaledByIncrementSize);
|
||||
}
|
||||
|
||||
public void InitOffsetted([NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE &")] in D3D12_CPU_DESCRIPTOR_HANDLE @base, int offsetInDescriptors, uint descriptorIncrementSize)
|
||||
{
|
||||
InitOffsetted(out this, @base, offsetInDescriptors, descriptorIncrementSize);
|
||||
}
|
||||
|
||||
public static void InitOffsetted([NativeTypeName("D3D12_CPU_DESCRIPTOR_HANDLE &")] out D3D12_CPU_DESCRIPTOR_HANDLE handle, [NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE &")] in D3D12_CPU_DESCRIPTOR_HANDLE @base, int offsetScaledByIncrementSize)
|
||||
{
|
||||
handle.ptr = (nuint)((long)@base.ptr + (long)offsetScaledByIncrementSize);
|
||||
}
|
||||
|
||||
public static void InitOffsetted([NativeTypeName("D3D12_CPU_DESCRIPTOR_HANDLE &")] out D3D12_CPU_DESCRIPTOR_HANDLE handle, [NativeTypeName("const D3D12_CPU_DESCRIPTOR_HANDLE &")] in D3D12_CPU_DESCRIPTOR_HANDLE @base, int offsetInDescriptors, uint descriptorIncrementSize)
|
||||
{
|
||||
handle.ptr = (nuint)((long)@base.ptr + ((long)offsetInDescriptors * (long)descriptorIncrementSize));
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj) => (obj is D3D12_CPU_DESCRIPTOR_HANDLE other) && Equals(other);
|
||||
|
||||
public bool Equals(D3D12_CPU_DESCRIPTOR_HANDLE other) => this == other;
|
||||
|
||||
public override int GetHashCode() => ptr.GetHashCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
using System;
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal unsafe partial struct D3D12_GPU_DESCRIPTOR_HANDLE : IEquatable<D3D12_GPU_DESCRIPTOR_HANDLE>
|
||||
{
|
||||
public static D3D12_GPU_DESCRIPTOR_HANDLE DEFAULT => default;
|
||||
|
||||
public D3D12_GPU_DESCRIPTOR_HANDLE([NativeTypeName("const D3D12_GPU_DESCRIPTOR_HANDLE &")] in D3D12_GPU_DESCRIPTOR_HANDLE other, int offsetScaledByIncrementSize)
|
||||
{
|
||||
InitOffsetted(out this, other, offsetScaledByIncrementSize);
|
||||
}
|
||||
|
||||
public D3D12_GPU_DESCRIPTOR_HANDLE([NativeTypeName("const D3D12_GPU_DESCRIPTOR_HANDLE &")] in D3D12_GPU_DESCRIPTOR_HANDLE other, int offsetInDescriptors, uint descriptorIncrementSize)
|
||||
{
|
||||
InitOffsetted(out this, other, offsetInDescriptors, descriptorIncrementSize);
|
||||
}
|
||||
|
||||
public D3D12_GPU_DESCRIPTOR_HANDLE Offset(int offsetInDescriptors, uint descriptorIncrementSize)
|
||||
{
|
||||
ptr = (ulong)((long)ptr + ((long)offsetInDescriptors * (long)descriptorIncrementSize));
|
||||
return this;
|
||||
}
|
||||
|
||||
public D3D12_GPU_DESCRIPTOR_HANDLE Offset(int offsetScaledByIncrementSize)
|
||||
{
|
||||
ptr = (ulong)((long)ptr + (long)offsetScaledByIncrementSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static bool operator ==([NativeTypeName("const D3D12_GPU_DESCRIPTOR_HANDLE &")] in D3D12_GPU_DESCRIPTOR_HANDLE l, [NativeTypeName("const D3D12_GPU_DESCRIPTOR_HANDLE &")] in D3D12_GPU_DESCRIPTOR_HANDLE r)
|
||||
=> (l.ptr == r.ptr);
|
||||
|
||||
public static bool operator !=([NativeTypeName("const D3D12_GPU_DESCRIPTOR_HANDLE &")] in D3D12_GPU_DESCRIPTOR_HANDLE l, [NativeTypeName("const D3D12_GPU_DESCRIPTOR_HANDLE &")] in D3D12_GPU_DESCRIPTOR_HANDLE r)
|
||||
=> (l.ptr != r.ptr);
|
||||
|
||||
public void InitOffsetted([NativeTypeName("const D3D12_GPU_DESCRIPTOR_HANDLE &")] in D3D12_GPU_DESCRIPTOR_HANDLE @base, int offsetScaledByIncrementSize)
|
||||
{
|
||||
InitOffsetted(out this, @base, offsetScaledByIncrementSize);
|
||||
}
|
||||
|
||||
public void InitOffsetted([NativeTypeName("const D3D12_GPU_DESCRIPTOR_HANDLE &")] in D3D12_GPU_DESCRIPTOR_HANDLE @base, int offsetInDescriptors, uint descriptorIncrementSize)
|
||||
{
|
||||
InitOffsetted(out this, @base, offsetInDescriptors, descriptorIncrementSize);
|
||||
}
|
||||
|
||||
public static void InitOffsetted([NativeTypeName("D3D12_GPU_DESCRIPTOR_HANDLE &")] out D3D12_GPU_DESCRIPTOR_HANDLE handle, [NativeTypeName("const D3D12_GPU_DESCRIPTOR_HANDLE &")] in D3D12_GPU_DESCRIPTOR_HANDLE @base, int offsetScaledByIncrementSize)
|
||||
{
|
||||
handle.ptr = (ulong)((long)@base.ptr + (long)offsetScaledByIncrementSize);
|
||||
}
|
||||
|
||||
public static void InitOffsetted([NativeTypeName("D3D12_GPU_DESCRIPTOR_HANDLE &")] out D3D12_GPU_DESCRIPTOR_HANDLE handle, [NativeTypeName("const D3D12_GPU_DESCRIPTOR_HANDLE &")] in D3D12_GPU_DESCRIPTOR_HANDLE @base, int offsetInDescriptors, uint descriptorIncrementSize)
|
||||
{
|
||||
handle.ptr = (ulong)((long)@base.ptr + ((long)offsetInDescriptors * (long)descriptorIncrementSize));
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj) => (obj is D3D12_GPU_DESCRIPTOR_HANDLE other) && Equals(other);
|
||||
|
||||
public bool Equals(D3D12_GPU_DESCRIPTOR_HANDLE other) => this == other;
|
||||
|
||||
public override int GetHashCode() => ptr.GetHashCode();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal partial struct D3D12_RESOURCE_ALLOCATION_INFO
|
||||
{
|
||||
public D3D12_RESOURCE_ALLOCATION_INFO([NativeTypeName("UINT64")] ulong size, [NativeTypeName("UINT64")] ulong alignment)
|
||||
{
|
||||
SizeInBytes = size;
|
||||
Alignment = alignment;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
using static TerraFX.Interop.DirectX.D3D12;
|
||||
using static TerraFX.Interop.DirectX.D3D12_RESOURCE_BARRIER_FLAGS;
|
||||
using static TerraFX.Interop.DirectX.D3D12_RESOURCE_BARRIER_TYPE;
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal unsafe partial struct D3D12_RESOURCE_BARRIER
|
||||
{
|
||||
public static D3D12_RESOURCE_BARRIER InitTransition(ID3D12Resource* pResource, D3D12_RESOURCE_STATES stateBefore, D3D12_RESOURCE_STATES stateAfter, uint subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE)
|
||||
{
|
||||
D3D12_RESOURCE_BARRIER result = default;
|
||||
result.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||
result.Flags = flags;
|
||||
result.Anonymous.Transition.pResource = pResource;
|
||||
result.Anonymous.Transition.StateBefore = stateBefore;
|
||||
result.Anonymous.Transition.StateAfter = stateAfter;
|
||||
result.Anonymous.Transition.Subresource = subresource;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static D3D12_RESOURCE_BARRIER InitAliasing(ID3D12Resource* pResourceBefore, ID3D12Resource* pResourceAfter)
|
||||
{
|
||||
D3D12_RESOURCE_BARRIER result = default;
|
||||
result.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING;
|
||||
result.Anonymous.Aliasing.pResourceBefore = pResourceBefore;
|
||||
result.Anonymous.Aliasing.pResourceAfter = pResourceAfter;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static D3D12_RESOURCE_BARRIER InitUAV(ID3D12Resource* pResource)
|
||||
{
|
||||
D3D12_RESOURCE_BARRIER result = default;
|
||||
result.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
|
||||
result.Anonymous.UAV.pResource = pResource;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
using System;
|
||||
using static TerraFX.Interop.DirectX.D3D12_RESOURCE_DIMENSION;
|
||||
using static TerraFX.Interop.DirectX.D3D12_RESOURCE_FLAGS;
|
||||
using static TerraFX.Interop.DirectX.D3D12_TEXTURE_LAYOUT;
|
||||
using static TerraFX.Interop.DirectX.DirectX;
|
||||
using static TerraFX.Interop.DirectX.DXGI_FORMAT;
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal unsafe partial struct D3D12_RESOURCE_DESC : IEquatable<D3D12_RESOURCE_DESC>
|
||||
{
|
||||
public D3D12_RESOURCE_DESC(D3D12_RESOURCE_DIMENSION dimension, [NativeTypeName("UINT64")] ulong alignment, [NativeTypeName("UINT64")] ulong width, uint height, [NativeTypeName("UINT16")] ushort depthOrArraySize, [NativeTypeName("UINT16")] ushort mipLevels, DXGI_FORMAT format, uint sampleCount, uint sampleQuality, D3D12_TEXTURE_LAYOUT layout, D3D12_RESOURCE_FLAGS flags)
|
||||
{
|
||||
Dimension = dimension;
|
||||
Alignment = alignment;
|
||||
Width = width;
|
||||
Height = height;
|
||||
DepthOrArraySize = depthOrArraySize;
|
||||
MipLevels = mipLevels;
|
||||
Format = format;
|
||||
SampleDesc.Count = sampleCount;
|
||||
SampleDesc.Quality = sampleQuality;
|
||||
Layout = layout;
|
||||
Flags = flags;
|
||||
}
|
||||
|
||||
public static D3D12_RESOURCE_DESC Buffer([NativeTypeName("const D3D12_RESOURCE_ALLOCATION_INFO &")] in D3D12_RESOURCE_ALLOCATION_INFO resAllocInfo, D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE)
|
||||
{
|
||||
return new D3D12_RESOURCE_DESC(D3D12_RESOURCE_DIMENSION_BUFFER, resAllocInfo.Alignment, resAllocInfo.SizeInBytes, 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags);
|
||||
}
|
||||
|
||||
public static D3D12_RESOURCE_DESC Buffer([NativeTypeName("UINT64")] ulong width, D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, [NativeTypeName("UINT64")] ulong alignment = 0)
|
||||
{
|
||||
return new D3D12_RESOURCE_DESC(D3D12_RESOURCE_DIMENSION_BUFFER, alignment, width, 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags);
|
||||
}
|
||||
|
||||
public static D3D12_RESOURCE_DESC Tex1D(DXGI_FORMAT format, [NativeTypeName("UINT64")] ulong width, [NativeTypeName("UINT16")] ushort arraySize = 1, [NativeTypeName("UINT16")] ushort mipLevels = 0, D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, [NativeTypeName("UINT64")] ulong alignment = 0)
|
||||
{
|
||||
return new D3D12_RESOURCE_DESC(D3D12_RESOURCE_DIMENSION_TEXTURE1D, alignment, width, 1, arraySize, mipLevels, format, 1, 0, layout, flags);
|
||||
}
|
||||
|
||||
public static D3D12_RESOURCE_DESC Tex2D(DXGI_FORMAT format, [NativeTypeName("UINT64")] ulong width, uint height, [NativeTypeName("UINT16")] ushort arraySize = 1, [NativeTypeName("UINT16")] ushort mipLevels = 0, uint sampleCount = 1, uint sampleQuality = 0, D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, [NativeTypeName("UINT64")] ulong alignment = 0)
|
||||
{
|
||||
return new D3D12_RESOURCE_DESC(D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment, width, height, arraySize, mipLevels, format, sampleCount, sampleQuality, layout, flags);
|
||||
}
|
||||
|
||||
public static D3D12_RESOURCE_DESC Tex3D(DXGI_FORMAT format, [NativeTypeName("UINT64")] ulong width, uint height, [NativeTypeName("UINT16")] ushort depth, [NativeTypeName("UINT16")] ushort mipLevels = 0, D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, [NativeTypeName("UINT64")] ulong alignment = 0)
|
||||
{
|
||||
return new D3D12_RESOURCE_DESC(D3D12_RESOURCE_DIMENSION_TEXTURE3D, alignment, width, height, depth, mipLevels, format, 1, 0, layout, flags);
|
||||
}
|
||||
|
||||
public ushort Depth => ((Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D) ? DepthOrArraySize : (ushort)(1));
|
||||
|
||||
public ushort ArraySize => ((Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D) ? DepthOrArraySize : (ushort)(1));
|
||||
|
||||
public byte GetPlaneCount(ID3D12Device* pDevice)
|
||||
{
|
||||
return D3D12GetFormatPlaneCount(pDevice, Format);
|
||||
}
|
||||
|
||||
public uint GetSubresources(ID3D12Device* pDevice)
|
||||
{
|
||||
return MipLevels * (uint)ArraySize * GetPlaneCount(pDevice);
|
||||
}
|
||||
|
||||
public uint CalcSubresource(uint MipSlice, uint ArraySlice, uint PlaneSlice)
|
||||
{
|
||||
return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize);
|
||||
}
|
||||
|
||||
public static bool operator ==([NativeTypeName("const D3D12_RESOURCE_DESC &")] in D3D12_RESOURCE_DESC l, [NativeTypeName("const D3D12_RESOURCE_DESC &")] in D3D12_RESOURCE_DESC r)
|
||||
{
|
||||
return (l.Dimension == r.Dimension)
|
||||
&& (l.Alignment == r.Alignment)
|
||||
&& (l.Width == r.Width)
|
||||
&& (l.Height == r.Height)
|
||||
&& (l.DepthOrArraySize == r.DepthOrArraySize)
|
||||
&& (l.MipLevels == r.MipLevels)
|
||||
&& (l.Format == r.Format)
|
||||
&& (l.SampleDesc.Count == r.SampleDesc.Count)
|
||||
&& (l.SampleDesc.Quality == r.SampleDesc.Quality)
|
||||
&& (l.Layout == r.Layout)
|
||||
&& (l.Flags == r.Flags);
|
||||
}
|
||||
|
||||
public static bool operator !=([NativeTypeName("const D3D12_RESOURCE_DESC &")] in D3D12_RESOURCE_DESC l, [NativeTypeName("const D3D12_RESOURCE_DESC &")] in D3D12_RESOURCE_DESC r)
|
||||
=> !(l == r);
|
||||
|
||||
public override bool Equals(object? obj) => (obj is D3D12_RESOURCE_DESC other) && Equals(other);
|
||||
|
||||
public bool Equals(D3D12_RESOURCE_DESC other) => this == other;
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
var hashCode = new HashCode();
|
||||
{
|
||||
hashCode.Add(Dimension);
|
||||
hashCode.Add(Alignment);
|
||||
hashCode.Add(Width);
|
||||
hashCode.Add(Height);
|
||||
hashCode.Add(DepthOrArraySize);
|
||||
hashCode.Add(MipLevels);
|
||||
hashCode.Add(Format);
|
||||
hashCode.Add(SampleDesc);
|
||||
hashCode.Add(Layout);
|
||||
hashCode.Add(Flags);
|
||||
}
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal unsafe partial struct D3D12_ROOT_CONSTANTS
|
||||
{
|
||||
public D3D12_ROOT_CONSTANTS(uint num32BitValues, uint shaderRegister, uint registerSpace = 0)
|
||||
{
|
||||
Init(out this, num32BitValues, shaderRegister, registerSpace);
|
||||
}
|
||||
|
||||
public void Init(uint num32BitValues, uint shaderRegister, uint registerSpace = 0)
|
||||
{
|
||||
Init(out this, num32BitValues, shaderRegister, registerSpace);
|
||||
}
|
||||
|
||||
public static void Init([NativeTypeName("D3D12_ROOT_CONSTANTS &")] out D3D12_ROOT_CONSTANTS rootConstants, uint num32BitValues, uint shaderRegister, uint registerSpace = 0)
|
||||
{
|
||||
rootConstants.Num32BitValues = num32BitValues;
|
||||
rootConstants.ShaderRegister = shaderRegister;
|
||||
rootConstants.RegisterSpace = registerSpace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal unsafe partial struct D3D12_ROOT_DESCRIPTOR
|
||||
{
|
||||
public D3D12_ROOT_DESCRIPTOR(uint shaderRegister, uint registerSpace = 0)
|
||||
{
|
||||
Init(out this, shaderRegister, registerSpace);
|
||||
}
|
||||
|
||||
public void Init(uint shaderRegister, uint registerSpace = 0)
|
||||
{
|
||||
Init(out this, shaderRegister, registerSpace);
|
||||
}
|
||||
|
||||
public static void Init([NativeTypeName("D3D12_ROOT_DESCRIPTOR &")] out D3D12_ROOT_DESCRIPTOR table, uint shaderRegister, uint registerSpace = 0)
|
||||
{
|
||||
table.ShaderRegister = shaderRegister;
|
||||
table.RegisterSpace = registerSpace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
using static TerraFX.Interop.DirectX.D3D12_ROOT_DESCRIPTOR_FLAGS;
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal unsafe partial struct D3D12_ROOT_DESCRIPTOR1
|
||||
{
|
||||
public D3D12_ROOT_DESCRIPTOR1(uint shaderRegister, uint registerSpace = 0, D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE)
|
||||
{
|
||||
Init(out this, shaderRegister, registerSpace, flags);
|
||||
}
|
||||
|
||||
public void Init(uint shaderRegister, uint registerSpace = 0, D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE)
|
||||
{
|
||||
Init(out this, shaderRegister, registerSpace, flags);
|
||||
}
|
||||
|
||||
public static void Init([NativeTypeName("D3D12_ROOT_DESCRIPTOR1 &")] out D3D12_ROOT_DESCRIPTOR1 table, uint shaderRegister, uint registerSpace = 0, D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE)
|
||||
{
|
||||
table.ShaderRegister = shaderRegister;
|
||||
table.RegisterSpace = registerSpace;
|
||||
table.Flags = flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal unsafe partial struct D3D12_ROOT_DESCRIPTOR_TABLE1
|
||||
{
|
||||
public D3D12_ROOT_DESCRIPTOR_TABLE1(uint numDescriptorRanges, [NativeTypeName("const D3D12_DESCRIPTOR_RANGE1 *")] D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges)
|
||||
{
|
||||
Init(out this, numDescriptorRanges, _pDescriptorRanges);
|
||||
}
|
||||
|
||||
public void Init(uint numDescriptorRanges, [NativeTypeName("const D3D12_DESCRIPTOR_RANGE1 *")] D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges)
|
||||
{
|
||||
Init(out this, numDescriptorRanges, _pDescriptorRanges);
|
||||
}
|
||||
|
||||
public static void Init([NativeTypeName("D3D12_ROOT_DESCRIPTOR_TABLE &")] out D3D12_ROOT_DESCRIPTOR_TABLE1 rootDescriptorTable, uint numDescriptorRanges, [NativeTypeName("const D3D12_DESCRIPTOR_RANGE1 *")] D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges)
|
||||
{
|
||||
rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges;
|
||||
rootDescriptorTable.pDescriptorRanges = _pDescriptorRanges;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
|
||||
|
||||
// Ported from d3dx12.h in DirectX-Graphics-Samples commit a7a87f1853b5540f10920518021d91ae641033fb
|
||||
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the MIT License (MIT).
|
||||
|
||||
using static TerraFX.Interop.DirectX.D3D12_ROOT_PARAMETER_TYPE;
|
||||
using static TerraFX.Interop.DirectX.D3D12_SHADER_VISIBILITY;
|
||||
|
||||
namespace TerraFX.Interop.DirectX
|
||||
{
|
||||
internal unsafe partial struct D3D12_ROOT_PARAMETER1
|
||||
{
|
||||
public static void InitAsDescriptorTable([NativeTypeName("D3D12_ROOT_PARAMETER1 &")] out D3D12_ROOT_PARAMETER1 rootParam, uint numDescriptorRanges, [NativeTypeName("const D3D12_DESCRIPTOR_RANGE1 *")] D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
rootParam = default;
|
||||
|
||||
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
|
||||
rootParam.ShaderVisibility = visibility;
|
||||
D3D12_ROOT_DESCRIPTOR_TABLE1.Init(out rootParam.Anonymous.DescriptorTable, numDescriptorRanges, pDescriptorRanges);
|
||||
}
|
||||
|
||||
public static void InitAsConstants([NativeTypeName("D3D12_ROOT_PARAMETER1 &")] out D3D12_ROOT_PARAMETER1 rootParam, uint num32BitValues, uint shaderRegister, uint registerSpace = 0, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
rootParam = default;
|
||||
|
||||
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
|
||||
rootParam.ShaderVisibility = visibility;
|
||||
D3D12_ROOT_CONSTANTS.Init(out rootParam.Anonymous.Constants, num32BitValues, shaderRegister, registerSpace);
|
||||
}
|
||||
|
||||
public static void InitAsConstantBufferView([NativeTypeName("D3D12_ROOT_PARAMETER1 &")] out D3D12_ROOT_PARAMETER1 rootParam, uint shaderRegister, uint registerSpace = 0, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
rootParam = default;
|
||||
|
||||
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
|
||||
rootParam.ShaderVisibility = visibility;
|
||||
D3D12_ROOT_DESCRIPTOR1.Init(out rootParam.Anonymous.Descriptor, shaderRegister, registerSpace);
|
||||
}
|
||||
|
||||
public static void InitAsShaderResourceView([NativeTypeName("D3D12_ROOT_PARAMETER1 &")] out D3D12_ROOT_PARAMETER1 rootParam, uint shaderRegister, uint registerSpace = 0, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
rootParam = default;
|
||||
|
||||
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV;
|
||||
rootParam.ShaderVisibility = visibility;
|
||||
D3D12_ROOT_DESCRIPTOR1.Init(out rootParam.Anonymous.Descriptor, shaderRegister, registerSpace);
|
||||
}
|
||||
|
||||
public static void InitAsUnorderedAccessView([NativeTypeName("D3D12_ROOT_PARAMETER1 &")] out D3D12_ROOT_PARAMETER1 rootParam, uint shaderRegister, uint registerSpace = 0, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
rootParam = default;
|
||||
|
||||
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV;
|
||||
rootParam.ShaderVisibility = visibility;
|
||||
D3D12_ROOT_DESCRIPTOR1.Init(out rootParam.Anonymous.Descriptor, shaderRegister, registerSpace);
|
||||
}
|
||||
|
||||
public void InitAsDescriptorTable(uint numDescriptorRanges, [NativeTypeName("const D3D12_DESCRIPTOR_RANGE1 *")] D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
InitAsDescriptorTable(out this, numDescriptorRanges, pDescriptorRanges, visibility);
|
||||
}
|
||||
|
||||
public void InitAsConstants(uint num32BitValues, uint shaderRegister, uint registerSpace = 0, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
InitAsConstants(out this, num32BitValues, shaderRegister, registerSpace, visibility);
|
||||
}
|
||||
|
||||
public void InitAsConstantBufferView(uint shaderRegister, uint registerSpace = 0, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
InitAsConstantBufferView(out this, shaderRegister, registerSpace, visibility);
|
||||
}
|
||||
|
||||
public void InitAsShaderResourceView(uint shaderRegister, uint registerSpace = 0, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
InitAsShaderResourceView(out this, shaderRegister, registerSpace, visibility);
|
||||
}
|
||||
|
||||
public void InitAsUnorderedAccessView(uint shaderRegister, uint registerSpace = 0, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
|
||||
{
|
||||
InitAsUnorderedAccessView(out this, shaderRegister, registerSpace, visibility);
|
||||
}
|
||||
}
|
||||
}
|
||||
745ファイル中100ファイルを読み込みました。 変更されたファイルが多すぎるため、それ以降のファイルは表示していません。
さらに表示
新しいイシューから参照
ユーザーをブロックする