diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index 077e3de4..e307114c 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -79,6 +79,9 @@ jobs:
- name: Build ComputeSharp.D2D1 package
run: dotnet build src\ComputeSharp.D2D1.Package\ComputeSharp.D2D1.Package.msbuildproj -c Release
shell: cmd
+ - name: Build ComputeSharp.Pix package
+ run: dotnet build src\ComputeSharp.Pix.Package\ComputeSharp.Pix.Package.msbuildproj -c Release
+ shell: cmd
- name: Build ComputeSharp.Uwp package
run: msbuild src\ComputeSharp.Uwp\ComputeSharp.Uwp.csproj -t:restore,build,pack /p:Configuration=Release
shell: cmd
@@ -248,23 +251,101 @@ jobs:
with:
name: nuget_preview
path: artifacts
- - name: Build ComputeSharp.Sample.NuGet (.NET 6)
- run: dotnet build samples\ComputeSharp.Sample.NuGet\ComputeSharp.Sample.NuGet.csproj -c Release -f net6.0
+ - name: Build ComputeSharp.NuGet (.NET 6)
+ run: dotnet build tests\ComputeSharp.NuGet\ComputeSharp.NuGet.csproj -c Release -f net6.0
shell: cmd
- - name: Run ComputeSharp.Sample.NuGet (.NET 6)
- run: dotnet samples\ComputeSharp.Sample.NuGet\bin\Release\net6.0\ComputeSharp.Sample.NuGet.dll
+ - name: Run ComputeSharp.NuGet (.NET 6)
+ run: dotnet tests\ComputeSharp.NuGet\bin\Release\net6.0\ComputeSharp.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
+ - name: Build ComputeSharp.NuGet (.NET Core 3.1)
+ run: dotnet build tests\ComputeSharp.NuGet\ComputeSharp.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
+ - name: Run ComputeSharp.NuGet (.NET Core 3.1)
+ run: tests\ComputeSharp.NuGet\bin\Release\netcoreapp3.1\win-x64\ComputeSharp.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
+ - name: Build ComputeSharp.NuGet (.NET Framework 4.7.2)
+ run: dotnet build tests\ComputeSharp.NuGet\ComputeSharp.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
+ - name: Run ComputeSharp.NuGet (.NET Framework 4.7.2)
+ run: tests\ComputeSharp.NuGet\bin\x64\Release\net472\ComputeSharp.NuGet.exe
+ shell: cmd
+
+ # Download the NuGet packages and test the ComputeSharp.Dynamic dependency
+ verify-packages-dynamic:
+ if: success()
+ needs: [build-packages]
+ runs-on: windows-2022
+ steps:
+ - name: Git checkout
+ uses: actions/checkout@v2
+ - name: Setup .NET 6 SDK
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 6.0.x
+ - name: Create local NuGet feed
+ run: mkdir artifacts
+ shell: cmd
+ - name: Download package artifacts
+ uses: actions/download-artifact@v2
+ with:
+ name: nuget_preview
+ path: artifacts
+ - name: Build ComputeSharp.Dynamic.NuGet (.NET 6)
+ run: dotnet build tests\ComputeSharp.Dynamic.NuGet\ComputeSharp.Dynamic.NuGet.csproj -c Release -f net6.0
+ shell: cmd
+ - name: Run ComputeSharp.Dynamic.NuGet (.NET 6)
+ run: dotnet tests\ComputeSharp.Dynamic.NuGet\bin\Release\net6.0\ComputeSharp.Dynamic.NuGet.dll
+ shell: cmd
+ - name: Build ComputeSharp.Dynamic.NuGet (.NET Core 3.1)
+ run: dotnet build tests\ComputeSharp.Dynamic.NuGet\ComputeSharp.Dynamic.NuGet.csproj -c Release -f netcoreapp3.1 -r win-x64
+ shell: cmd
+ - name: Run ComputeSharp.Dynamic.NuGet (.NET Core 3.1)
+ run: tests\ComputeSharp.Dynamic.NuGet\bin\Release\netcoreapp3.1\win-x64\ComputeSharp.Dynamic.NuGet.exe
+ shell: cmd
+ - name: Build ComputeSharp.Dynamic.NuGet (.NET Framework 4.7.2)
+ run: dotnet build tests\ComputeSharp.Dynamic.NuGet\ComputeSharp.Dynamic.NuGet.csproj -c Release -f net472 /p:Platform=x64
+ shell: cmd
+ - name: Run ComputeSharp.Dynamic.NuGet (.NET Framework 4.7.2)
+ run: tests\ComputeSharp.Dynamic.NuGet\bin\x64\Release\net472\ComputeSharp.Dynamic.NuGet.exe
+ shell: cmd
+
+ # Download the NuGet packages and test the ComputeSharp.Pix dependency
+ verify-packages-pix:
+ if: success()
+ needs: [build-packages]
+ runs-on: windows-2022
+ steps:
+ - name: Git checkout
+ uses: actions/checkout@v2
+ - name: Setup .NET 6 SDK
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 6.0.x
+ - name: Create local NuGet feed
+ run: mkdir artifacts
+ shell: cmd
+ - name: Download package artifacts
+ uses: actions/download-artifact@v2
+ with:
+ name: nuget_preview
+ path: artifacts
+ - name: Build ComputeSharp.Pix.NuGet (.NET 6)
+ run: dotnet build tests\ComputeSharp.Pix.NuGet\ComputeSharp.Pix.NuGet.csproj -c Release -f net6.0
+ shell: cmd
+ - name: Run ComputeSharp.Pix.NuGet (.NET 6)
+ run: dotnet tests\ComputeSharp.Pix.NuGet\bin\Release\net6.0\ComputeSharp.Pix.NuGet.dll
+ shell: cmd
+ - name: Build ComputeSharp.Pix.NuGet (.NET Core 3.1)
+ run: dotnet build tests\ComputeSharp.Pix.NuGet\ComputeSharp.Pix.NuGet.csproj -c Release -f netcoreapp3.1 -r win-x64
+ shell: cmd
+ - name: Run ComputeSharp.Pix.NuGet (.NET Core 3.1)
+ run: tests\ComputeSharp.Pix.NuGet\bin\Release\netcoreapp3.1\win-x64\ComputeSharp.Pix.NuGet.exe
+ shell: cmd
+ - name: Build ComputeSharp.Pix.NuGet (.NET Framework 4.7.2)
+ run: dotnet build tests\ComputeSharp.Pix.NuGet\ComputeSharp.Pix.NuGet.csproj -c Release -f net472 /p:Platform=x64
+ shell: cmd
+ - name: Run ComputeSharp.Pix.NuGet (.NET Framework 4.7.2)
+ run: tests\ComputeSharp.Pix.NuGet\bin\x64\Release\net472\ComputeSharp.Pix.NuGet.exe
shell: cmd
# Run the extra tests to validate a number of build and publishing configurations.
@@ -287,7 +368,7 @@ jobs:
# Publish the packages to GitHub packages
publish-nightlies-github:
- needs: [ run-dx12-tests, run-d2d1-tests, run-dx12-samples, verify-packages, verify-package-native-libs ]
+ needs: [run-dx12-tests, run-d2d1-tests, run-dx12-samples, verify-packages, verify-packages-dynamic, verify-packages-pix, verify-package-native-libs]
runs-on: windows-2022
if: ${{github.event_name == 'push'}}
steps:
@@ -303,7 +384,7 @@ jobs:
# Publish the packages to Azure DevOps
publish-nightlies-azure-devops:
- needs: [ run-dx12-tests, run-d2d1-tests, run-dx12-samples, verify-packages, verify-package-native-libs ]
+ needs: [run-dx12-tests, run-d2d1-tests, run-dx12-samples, verify-packages, verify-packages-dynamic, verify-packages-pix, verify-package-native-libs]
runs-on: windows-2022
if: ${{github.event_name == 'push'}}
steps:
diff --git a/ComputeSharp.sln b/ComputeSharp.sln
index dc076252..880d7110 100644
--- a/ComputeSharp.sln
+++ b/ComputeSharp.sln
@@ -28,12 +28,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_SolutionItems", "_Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.SourceGenerators", "src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj", "{EB52CB67-4162-4722-874B-44EA8DA5450E}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{FB17EF84-9208-47AC-921F-680CB1DAD8BA}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packages", "Packages", "{FB17EF84-9208-47AC-921F-680CB1DAD8BA}"
ProjectSection(SolutionItems) = preProject
src\ComputeSharp.Core.Package\ComputeSharp.Core.Package.msbuildproj = src\ComputeSharp.Core.Package\ComputeSharp.Core.Package.msbuildproj
src\ComputeSharp.D2D1.Package\ComputeSharp.D2D1.Package.msbuildproj = src\ComputeSharp.D2D1.Package\ComputeSharp.D2D1.Package.msbuildproj
src\ComputeSharp.Dynamic.Package\ComputeSharp.Dynamic.Package.msbuildproj = src\ComputeSharp.Dynamic.Package\ComputeSharp.Dynamic.Package.msbuildproj
src\ComputeSharp.Package\ComputeSharp.Package.msbuildproj = src\ComputeSharp.Package\ComputeSharp.Package.msbuildproj
+ src\ComputeSharp.Pix.Package\ComputeSharp.Pix.Package.msbuildproj = src\ComputeSharp.Pix.Package\ComputeSharp.Pix.Package.msbuildproj
src\ComputeSharp.Core.Package\icon.png = src\ComputeSharp.Core.Package\icon.png
src\ComputeSharp.Core.Package\icon_highres.png = src\ComputeSharp.Core.Package\icon_highres.png
EndProjectSection
@@ -100,6 +101,29 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.D2D1.Tests", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.D2D1.Tests.AssemblyLevelAttributes", "tests\ComputeSharp.D2D1.Tests.AssemblyLevelAttributes\ComputeSharp.D2D1.Tests.AssemblyLevelAttributes.csproj", "{94178D51-0097-4AD2-B3D0-827E40D62F2E}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Pix", "src\ComputeSharp.Pix\ComputeSharp.Pix.csproj", "{14EF12A3-90E6-4683-BD71-9896AF87026B}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ComputeSharp.Dynamic.NuGet", "ComputeSharp.Dynamic.NuGet", "{CBA545B4-31EF-4E9F-A1A8-2A1290B54046}"
+ ProjectSection(SolutionItems) = preProject
+ tests\ComputeSharp.Dynamic.NuGet\ComputeSharp.Dynamic.NuGet.csproj = tests\ComputeSharp.Dynamic.NuGet\ComputeSharp.Dynamic.NuGet.csproj
+ tests\ComputeSharp.Dynamic.NuGet\nuget.config = tests\ComputeSharp.Dynamic.NuGet\nuget.config
+ tests\ComputeSharp.Dynamic.NuGet\Program.cs = tests\ComputeSharp.Dynamic.NuGet\Program.cs
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ComputeSharp.Pix.NuGet", "ComputeSharp.Pix.NuGet", "{C0B903AA-F32C-4760-B4B6-199AC4FE1C5A}"
+ ProjectSection(SolutionItems) = preProject
+ tests\ComputeSharp.Pix.NuGet\ComputeSharp.Pix.NuGet.csproj = tests\ComputeSharp.Pix.NuGet\ComputeSharp.Pix.NuGet.csproj
+ tests\ComputeSharp.Pix.NuGet\nuget.config = tests\ComputeSharp.Pix.NuGet\nuget.config
+ tests\ComputeSharp.Pix.NuGet\Program.cs = tests\ComputeSharp.Pix.NuGet\Program.cs
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ComputeSharp.NuGet", "ComputeSharp.NuGet", "{E3403F19-A0D8-4317-8A54-322C7A13F2A2}"
+ ProjectSection(SolutionItems) = preProject
+ tests\ComputeSharp.NuGet\ComputeSharp.NuGet.csproj = tests\ComputeSharp.NuGet\ComputeSharp.NuGet.csproj
+ tests\ComputeSharp.NuGet\nuget.config = tests\ComputeSharp.NuGet\nuget.config
+ tests\ComputeSharp.NuGet\Program.cs = tests\ComputeSharp.NuGet\Program.cs
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -410,6 +434,18 @@ Global
{94178D51-0097-4AD2-B3D0-827E40D62F2E}.Release|ARM64.Build.0 = Release|Any CPU
{94178D51-0097-4AD2-B3D0-827E40D62F2E}.Release|x64.ActiveCfg = Release|Any CPU
{94178D51-0097-4AD2-B3D0-827E40D62F2E}.Release|x64.Build.0 = Release|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Debug|ARM64.Build.0 = Debug|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Debug|x64.Build.0 = Debug|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Release|ARM64.Build.0 = Release|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Release|x64.ActiveCfg = Release|Any CPU
+ {14EF12A3-90E6-4683-BD71-9896AF87026B}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -439,6 +475,9 @@ Global
{3ACACF03-6B20-40BA-B8EC-11AC1624D2C9} = {8DCE343F-BA78-4FE1-B562-B57C603A8BAA}
{209C95A3-FA53-431B-B688-3299CA6C29D2} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
{94178D51-0097-4AD2-B3D0-827E40D62F2E} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
+ {CBA545B4-31EF-4E9F-A1A8-2A1290B54046} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
+ {C0B903AA-F32C-4760-B4B6-199AC4FE1C5A} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
+ {E3403F19-A0D8-4317-8A54-322C7A13F2A2} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4664C5E3-0340-4E22-BCFD-98AAEDF5F2DC}
diff --git a/LICENSE b/LICENSE
index 948574b9..c13364da 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2019 Sergio Pedri
+Copyright (c) 2022 Sergio Pedri
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index e574a8da..5fcc1202 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,7 @@ The sample app is available in the Microsoft Store, showcasing several pixel sha
| ------ | ------ | ------ |
| **ComputeSharp** | The main library, with compiled shaders support | [](https://www.nuget.org/packages/ComputeSharp/) |
| **ComputeSharp.Dynamic** | An extension for **ComputeSharp**, enabling dynamic shader compilation at runtime and shader metaprogramming | [](https://www.nuget.org/packages/ComputeSharp.Dynamic/) |
+| **ComputeSharp.Pix** | An extension library for **ComputeSharp**, enabling PIX support to produce debugging information | [](https://www.nuget.org/packages/ComputeSharp.Pix/) |
| **ComputeSharp.Uwp** | A UWP library (targeting .NET Standard 2.0) with controls to render DX12 shaders powered by **ComputeSharp** | [](https://www.nuget.org/packages/ComputeSharp.Uwp/) |
| **ComputeSharp.WinUI** | A WinUI 3 library (targeting .NET 6) with controls to render DX12 shaders powered by **ComputeSharp** | [](https://www.nuget.org/packages/ComputeSharp.WinUI/) |
| **ComputeSharp.D2D1** | A library to write D2D1 pixel shaders entirely with C# code, and to easily register and create ID2D1Effect-s from them | [](https://www.nuget.org/packages/ComputeSharp.D2D1/) |
diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt
new file mode 100644
index 00000000..086cfccc
--- /dev/null
+++ b/ThirdPartyNotices.txt
@@ -0,0 +1,89 @@
+THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
+Do Not Translate or Localize
+
+This project incorporates components from the projects listed below.
+
+1. PIX on Windows (https://devblogs.microsoft.com/pix/winpixeventruntime/), included in ComputeSharp.Pix.
+
+%% PIX on Windows NOTICES AND INFORMATION BEGIN HERE
+=========================================
+MICROSOFT SOFTWARE LICENSE TERMS
+
+PIX EVENT RUNTIME FOR WINDOWS
+
+IF YOU LIVE IN (OR ARE A BUSINESS WITH A PRINCIPAL PLACE OF BUSINESS IN) THE UNITED STATES, PLEASE READ THE “BINDING ARBITRATION AND CLASS ACTION WAIVER” SECTION BELOW. IT AFFECTS HOW DISPUTES ARE RESOLVED.
+
+These license terms are an agreement between you and Microsoft Corporation (or one of its affiliates). They apply to the software named above and any Microsoft services or software updates (except to the extent such services or updates are accompanied by new or additional terms, in which case those different terms apply prospectively and do not alter your or Microsoft’s rights relating to pre-updated software or services). IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS.
+
+1. INSTALLATION AND USE RIGHTS.
+ a. General. You may install and use any number of copies of the software to design, develop and test your Microsoft Windows programs.
+ b. Third Party Software. The software may include third party applications that are licensed to you under this agreement or under their own terms. License terms, notices, and acknowledgements, if any, for the third party applications may be accessible online at http://aka.ms/thirdpartynotices or in an accompanying notices file. Even if such applications are governed by other agreements, the disclaimer, limitations on, and exclusions of damages below also apply to the extent allowed by applicable law.
+
+2. DISTRIBUTABLE CODE.
+ a. Distributable Code. The software is comprised of Distributable Code. “Distributable Code” is code that you are permitted to distribute in programs you develop if you comply with the terms below.
+ (i) Right to Use and Distribute.
+ * You may copy and distribute the object code form of the software.
+ * Third Party Distribution. You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs.
+ (ii) Distribution Requirements. For any Distributable Code you distribute, you must
+ * add significant primary functionality to it in your programs;
+ * require distributors and external end users to agree to terms that protect it at least as much as this agreement;
+ * display your valid copyright notice on your programs; and
+ * indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your programs.
+ (iii) Distribution Restrictions. You may not
+ * alter any copyright, trademark or patent notice in the Distributable Code;
+ * use Microsoft’s trademarks in your programs’ names or in a way that suggests your programs come from or are endorsed by Microsoft;
+ * distribute Distributable Code to run on a platform other than a Windows platform;
+ * include Distributable Code in malicious, deceptive or unlawful programs; or
+ * modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a condition of use, modification or distribution, that
+ * the code be disclosed or distributed in source code form; or
+ * others have the right to modify it.
+
+3. SCOPE OF LICENSE. The software is licensed, not sold. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you will not (and have no right to):
+ a. work around any technical limitations in the software that only allow you to use it in certain ways;
+ b. reverse engineer, decompile or disassemble the software;
+ c. remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software;
+ d. use the software in any way that is against the law or to create or propagate malware; or
+ e. share, publish, distribute, or lend the software, provide the software as a stand-alone hosted solution for others to use, or transfer the software or this agreement to any third party.
+
+4. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit http://aka.ms/exporting.
+
+5. SUPPORT SERVICES. Microsoft is not obligated under this agreement to provide any support services for the software. Any support provided is “as is”, “with all faults”, and without warranty of any kind.
+
+6. BINDING ARBITRATION AND CLASS ACTION WAIVER. This Section applies if you live in (or, if a business, your principal place of business is in) the United States. If you and Microsoft have a dispute, you and Microsoft agree to try for 60 days to resolve it informally. If you and Microsoft can’t, you and Microsoft agree to binding individual arbitration before the American Arbitration Association under the Federal Arbitration Act (“FAA”), and not to sue in court in front of a judge or jury. Instead, a neutral arbitrator will decide. Class action lawsuits, class-wide arbitrations, private attorney-general actions, and any other proceeding where someone acts in a representative capacity are not allowed; nor is combining individual proceedings without the consent of all parties. The complete Arbitration Agreement contains more terms and is at http://aka.ms/arb-agreement-1. You and Microsoft agree to these terms.
+
+7. ENTIRE AGREEMENT. This agreement, and any other terms Microsoft may provide for supplements, updates, or third-party applications, is the entire agreement for the software.
+
+8. APPLICABLE LAW AND PLACE TO RESOLVE DISPUTES. If you acquired the software in the United States or Canada, the laws of the state or province where you live (or, if a business, where your principal place of business is located) govern the interpretation of this agreement, claims for its breach, and all other claims (including consumer protection, unfair competition, and tort claims), regardless of conflict of laws principles, except that the FAA governs everything related to arbitration. If you acquired the software in any other country, its laws apply, except that the FAA governs everything related to arbitration. If U.S. federal jurisdiction exists, you and Microsoft consent to exclusive jurisdiction and venue in the federal court in King County, Washington for all disputes heard in court (excluding arbitration). If not, you and Microsoft consent to exclusive jurisdiction and venue in the Superior Court of King County, Washington for all disputes heard in court (excluding arbitration).
+
+9. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state, province, or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state, province, or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you:
+ a. Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights.
+ b. Canada. If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software.
+ c. Germany and Austria.
+ (i) Warranty. The properly licensed software will perform substantially as described in any Microsoft materials that accompany the software. However, Microsoft gives no contractual guarantee in relation to the licensed software.
+ (ii) Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as, in case of death or personal or physical injury, Microsoft is liable according to the statutory law.
+ Subject to the foregoing clause (ii), Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence.
+
+10. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO THE EXTENT PERMITTED UNDER APPLICABLE LAWS, MICROSOFT EXCLUDES ALL IMPLIED WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+
+11. LIMITATION ON AND EXCLUSION OF DAMAGES. IF YOU HAVE ANY BASIS FOR RECOVERING DAMAGES DESPITE THE PRECEDING DISCLAIMER OF WARRANTY, YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.
+This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, warranty, guarantee, or condition; strict liability, negligence, or other tort; or any other claim; in each case to the extent permitted by applicable law.
+It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state, province, or country may not allow the exclusion or limitation of incidental, consequential, or other damages.
+
+
+[Please note: As this software is distributed in Canada, some of the clauses in this agreement are provided below in French.
+
+Remarque: Ce logiciel étant distribué au Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français.
+
+EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « tel quel ». Toute utilisation de ce logiciel est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues.
+
+LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices.
+
+Cette limitation concerne:
+ * tout ce qui est relié au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers; et
+ * les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur.
+
+Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage. Si votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera pas à votre égard.
+
+EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre pays si celles-ci ne le permettent pas.]
+=========================================
+END OF PIX on Windows NOTICES AND INFORMATION
\ No newline at end of file
diff --git a/src/ComputeSharp.Core.Package/ComputeSharp.Core.Package.msbuildproj b/src/ComputeSharp.Core.Package/ComputeSharp.Core.Package.msbuildproj
index 8cc7e0b0..909f3c38 100644
--- a/src/ComputeSharp.Core.Package/ComputeSharp.Core.Package.msbuildproj
+++ b/src/ComputeSharp.Core.Package/ComputeSharp.Core.Package.msbuildproj
@@ -21,9 +21,9 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs b/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs
index 111cf414..b7584b81 100644
--- a/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs
+++ b/src/ComputeSharp.Core.SourceGenerators/AutoConstructorGenerator.cs
@@ -16,7 +16,7 @@ namespace ComputeSharp.Core.SourceGenerators;
/// A source generator creating constructors for types annotated with .
///
[Generator(LanguageNames.CSharp)]
-public sealed partial class AutoConstructorGenerator : IIncrementalGenerator
+public sealed class AutoConstructorGenerator : IIncrementalGenerator
{
///
public void Initialize(IncrementalGeneratorInitializationContext context)
diff --git a/src/ComputeSharp.Core/ComputeSharp.Core.targets b/src/ComputeSharp.Core/ComputeSharp.Core.targets
index fce96d6e..c67a4d3f 100644
--- a/src/ComputeSharp.Core/ComputeSharp.Core.targets
+++ b/src/ComputeSharp.Core/ComputeSharp.Core.targets
@@ -18,20 +18,20 @@
the same version) but Microsoft.Build.Tasks.CodeAnalysis.dll is where MSBuild loads the compiler tasks from so if
someone is getting creative with msbuild tasks/targets this is the "most correct" assembly to check. -->
-
+
- @(CurrentCompilerAssemblyIdentity->'%(Version)')
+ @(ComputeSharpCoreCurrentCompilerAssemblyIdentity->'%(Version)')
- true
+ true
-
+
diff --git a/src/ComputeSharp.D2D1.Package/ComputeSharp.D2D1.Package.msbuildproj b/src/ComputeSharp.D2D1.Package/ComputeSharp.D2D1.Package.msbuildproj
index 3f073749..3b2b49c7 100644
--- a/src/ComputeSharp.D2D1.Package/ComputeSharp.D2D1.Package.msbuildproj
+++ b/src/ComputeSharp.D2D1.Package/ComputeSharp.D2D1.Package.msbuildproj
@@ -27,9 +27,9 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs b/src/ComputeSharp.D2D1.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs
index d722dd00..8e6bc2eb 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs
@@ -7,7 +7,7 @@ using static ComputeSharp.D2D1.SourceGenerators.Diagnostics.DiagnosticDescriptor
namespace ComputeSharp.D2D1.SourceGenerators.SyntaxRewriters;
///
-internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
+partial class HlslSourceRewriter : CSharpSyntaxRewriter
{
///
public override SyntaxNode? VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpressionSyntax node)
diff --git a/src/ComputeSharp.D2D1/ComputeSharp.D2D1.targets b/src/ComputeSharp.D2D1/ComputeSharp.D2D1.targets
index 802efd95..5d93c4cf 100644
--- a/src/ComputeSharp.D2D1/ComputeSharp.D2D1.targets
+++ b/src/ComputeSharp.D2D1/ComputeSharp.D2D1.targets
@@ -18,27 +18,27 @@
the same version) but Microsoft.Build.Tasks.CodeAnalysis.dll is where MSBuild loads the compiler tasks from so if
someone is getting creative with msbuild tasks/targets this is the "most correct" assembly to check. -->
-
+
- @(CurrentCompilerAssemblyIdentity->'%(Version)')
+ @(ComputeSharpD2D1CurrentCompilerAssemblyIdentity->'%(Version)')
- true
+ true
-
+
-
+
diff --git a/src/ComputeSharp.D2D1/Helpers/ThrowHelper.cs b/src/ComputeSharp.D2D1/Helpers/ThrowHelper.cs
index a2163e54..36fd8f77 100644
--- a/src/ComputeSharp.D2D1/Helpers/ThrowHelper.cs
+++ b/src/ComputeSharp.D2D1/Helpers/ThrowHelper.cs
@@ -6,7 +6,7 @@ namespace ComputeSharp.D2D1.Helpers;
///
/// Helper methods to efficiently throw exceptions.
///
-internal static partial class ThrowHelper
+internal static class ThrowHelper
{
///
/// Throws a new .
diff --git a/src/ComputeSharp.Dynamic/Attributes/__Internals/ShaderMethodSourceAttribute.HlslGeneration.cs b/src/ComputeSharp.Dynamic/Attributes/__Internals/ShaderMethodSourceAttribute.HlslGeneration.cs
index dd8e84ae..5c8031db 100644
--- a/src/ComputeSharp.Dynamic/Attributes/__Internals/ShaderMethodSourceAttribute.HlslGeneration.cs
+++ b/src/ComputeSharp.Dynamic/Attributes/__Internals/ShaderMethodSourceAttribute.HlslGeneration.cs
@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace ComputeSharp.__Internals;
///
-public sealed partial class ShaderMethodSourceAttribute : Attribute
+partial class ShaderMethodSourceAttribute : Attribute
{
///
/// Appends the mapped source code for the current method.
diff --git a/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.LibraryLoading.cs b/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.LibraryLoading.cs
index bfb872b0..437ae750 100644
--- a/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.LibraryLoading.cs
+++ b/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.LibraryLoading.cs
@@ -9,7 +9,7 @@ using TerraFX.Interop.Windows;
namespace ComputeSharp.Shaders.Translation;
///
-internal sealed unsafe partial class ShaderCompiler
+unsafe partial class ShaderCompiler
{
///
/// Initializes the DLL resolvers for the dxcompiler.dll and dxil.dll libraries.
diff --git a/src/ComputeSharp.Package/ComputeSharp.Package.msbuildproj b/src/ComputeSharp.Package/ComputeSharp.Package.msbuildproj
index dc84fbb6..d5b55295 100644
--- a/src/ComputeSharp.Package/ComputeSharp.Package.msbuildproj
+++ b/src/ComputeSharp.Package/ComputeSharp.Package.msbuildproj
@@ -27,9 +27,9 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/ComputeSharp.Pix.Package/ComputeSharp.Pix.Package.msbuildproj b/src/ComputeSharp.Pix.Package/ComputeSharp.Pix.Package.msbuildproj
new file mode 100644
index 00000000..d809f0c5
--- /dev/null
+++ b/src/ComputeSharp.Pix.Package/ComputeSharp.Pix.Package.msbuildproj
@@ -0,0 +1,51 @@
+
+
+
+ net6.0
+
+
+
+ ComputeSharp.Pix
+ ComputeSharp.Pix
+ An extension library for ComputeSharp to enable PIX support to produce debugging information
+
+
+
+
+
+
+
+
+
+
+
+
+ LICENSE.txt
+
+
+
+
+
+ PackageVersion=$(PackageVersion)
+
+
+ PackageVersion=$(PackageVersion)
+
+
+
+
+ PackageVersion=$(PackageVersion)
+
+
+ PackageVersion=$(PackageVersion)
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/ComputeSharp.Pix/ComputeContextExtensions.cs b/src/ComputeSharp.Pix/ComputeContextExtensions.cs
new file mode 100644
index 00000000..16de0c2a
--- /dev/null
+++ b/src/ComputeSharp.Pix/ComputeContextExtensions.cs
@@ -0,0 +1,281 @@
+using System;
+using System.Diagnostics;
+using System.Drawing;
+using ComputeSharp.Graphics.Commands;
+using ComputeSharp.Interop;
+
+namespace ComputeSharp;
+
+///
+/// A that contains extension methods using PIX APIs for the type.
+///
+public static class ComputeContextExtensions
+{
+ ///
+ /// Starts a PIX event on a target object.
+ ///
+ /// The to use to start the PIX event.
+ /// The color to use for the event (the alpha channel will be ignored).
+ /// The message to use for the event.
+ [Conditional("USE_PIX")]
+ public static unsafe void BeginEvent(this in ComputeContext context, Color color, string message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ int argb = color.ToArgb();
+ uint pixColor = Pix.PIX_COLOR((byte)((argb & 0x00FF0000) >> 16), (byte)((argb & 0x0000FF00) >> 8), (byte)(argb & 0x000000FF));
+
+ commandList.D3D12GraphicsCommandList->BeginEvent(pixColor, message);
+ }
+
+ ///
+ /// Starts a PIX event on a target object.
+ ///
+ /// The to use to start the PIX event.
+ /// The index to identify the group this event belongs to (PIX will choose a color to represent all entries in the group).
+ /// The message to use for the event.
+ [Conditional("USE_PIX")]
+ public static unsafe void BeginEvent(this in ComputeContext context, byte index, string message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ uint pixColor = Pix.PIX_COLOR_INDEX(index);
+
+ commandList.D3D12GraphicsCommandList->BeginEvent(pixColor, message);
+ }
+
+ ///
+ /// Starts a PIX event on a target object.
+ ///
+ /// The to use to start the PIX event.
+ /// The message to use for the event.
+ [Conditional("USE_PIX")]
+ public static unsafe void BeginEvent(this in ComputeContext context, string message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ commandList.D3D12GraphicsCommandList->BeginEvent(0, message);
+ }
+
+ ///
+ /// Starts a PIX event on a target object.
+ ///
+ /// The to use to start the PIX event.
+ /// The color to use for the event (the alpha channel will be ignored).
+ /// The message to use for the event (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -terminator. This allows callers
+ /// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
+ /// The compiler will automatically insert a terminator right past the end of the returned when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
+ /// Callers must take extra care to ensure the input message is in fact -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void BeginEventUnsafe(this in ComputeContext context, Color color, ReadOnlySpan message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ int argb = color.ToArgb();
+ uint pixColor = Pix.PIX_COLOR((byte)((argb & 0x00FF0000) >> 16), (byte)((argb & 0x0000FF00) >> 8), (byte)(argb & 0x000000FF));
+
+ commandList.D3D12GraphicsCommandList->BeginEventUnsafe(pixColor, message);
+ }
+
+ ///
+ /// Starts a PIX event on a target object.
+ ///
+ /// The to use to start the PIX event.
+ /// The index to identify the group this event belongs to (PIX will choose a color to represent all entries in the group).
+ /// The message to use for the event (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -terminator. This allows callers
+ /// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
+ /// The compiler will automatically insert a terminator right past the end of the returned when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
+ /// Callers must take extra care to ensure the input message is in fact -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void BeginEventUnsafe(this in ComputeContext context, byte index, ReadOnlySpan message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ uint pixColor = Pix.PIX_COLOR_INDEX(index);
+
+ commandList.D3D12GraphicsCommandList->BeginEventUnsafe(pixColor, message);
+ }
+
+ ///
+ /// Starts a PIX event on a target object.
+ ///
+ /// The to use to start the PIX event.
+ /// The message to use for the event (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -terminator. This allows callers
+ /// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
+ /// The compiler will automatically insert a terminator right past the end of the returned when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
+ /// Callers must take extra care to ensure the input message is in fact -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void BeginEventUnsafe(this in ComputeContext context, ReadOnlySpan message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ commandList.D3D12GraphicsCommandList->BeginEventUnsafe(0, message);
+ }
+
+ ///
+ /// Ends a PIX event on a target object.
+ ///
+ /// The to use to end the PIX event.
+ [Conditional("USE_PIX")]
+ public static unsafe void EndEvent(this in ComputeContext context)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ Pix.PIXEndEventOnCommandList(commandList.D3D12GraphicsCommandList);
+ }
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The to use to insert the PIX marker.
+ /// The color to use for the log (the alpha channel will be ignored).
+ /// The message to use for the marker.
+ [Conditional("USE_PIX")]
+ public static unsafe void Log(this in ComputeContext context, Color color, string message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ int argb = color.ToArgb();
+ uint pixColor = Pix.PIX_COLOR((byte)((argb & 0x00FF0000) >> 16), (byte)((argb & 0x0000FF00) >> 8), (byte)(argb & 0x000000FF));
+
+ commandList.D3D12GraphicsCommandList->SetPixMarker(pixColor, message);
+ }
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The to use to insert the PIX marker.
+ /// The index to identify the group this log belongs to (PIX will choose a color to represent all entries in the group).
+ /// The message to use for the marker.
+ [Conditional("USE_PIX")]
+ public static unsafe void Log(this in ComputeContext context, byte index, string message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ uint pixColor = Pix.PIX_COLOR_INDEX(index);
+
+ commandList.D3D12GraphicsCommandList->SetPixMarker(pixColor, message);
+ }
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The to use to insert the PIX marker.
+ /// The message to use for the marker.
+ [Conditional("USE_PIX")]
+ public static unsafe void Log(this in ComputeContext context, string message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ commandList.D3D12GraphicsCommandList->SetPixMarker(0, message);
+ }
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The to use to insert the PIX marker.
+ /// The color to use for the log (the alpha channel will be ignored).
+ /// The message to use for the marker (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -terminator. This allows callers
+ /// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
+ /// The compiler will automatically insert a terminator right past the end of the returned when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
+ /// Callers must take extra care to ensure the input message is in fact -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void LogUnsafe(this in ComputeContext context, Color color, ReadOnlySpan message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ int argb = color.ToArgb();
+ uint pixColor = Pix.PIX_COLOR((byte)((argb & 0x00FF0000) >> 16), (byte)((argb & 0x0000FF00) >> 8), (byte)(argb & 0x000000FF));
+
+ commandList.D3D12GraphicsCommandList->SetPixMarkerUnsafe(pixColor, message);
+ }
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The to use to insert the PIX marker.
+ /// The index to identify the group this log belongs to (PIX will choose a color to represent all entries in the group).
+ /// The message to use for the marker (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -terminator. This allows callers
+ /// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
+ /// The compiler will automatically insert a terminator right past the end of the returned when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
+ /// Callers must take extra care to ensure the input message is in fact -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void LogUnsafe(this in ComputeContext context, byte index, ReadOnlySpan message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ uint pixColor = Pix.PIX_COLOR_INDEX(index);
+
+ commandList.D3D12GraphicsCommandList->SetPixMarkerUnsafe(pixColor, message);
+ }
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The to use to insert the PIX marker.
+ /// The message to use for the marker (it's assumed to be a -terminated ANSI characters sequence).
+ ///
+ ///
+ /// The parameter is not checked to ensure it has a -terminator. This allows callers
+ /// to pass an UTF8 string literal containing only ASCII characters (as the byte contents would be a valid ANSI sequence in that case).
+ /// The compiler will automatically insert a terminator right past the end of the returned when doing so.
+ ///
+ ///
+ /// This method offers greatly reduced overhead compared to the overlods taking a , as there is no need to create the
+ /// instance nor to execute the transcoding at runtime. The behavior when the input is invalid though is undefined.
+ /// Callers must take extra care to ensure the input message is in fact -terminated when invoking this API.
+ ///
+ ///
+ [Conditional("USE_PIX")]
+ public static unsafe void LogUnsafe(this in ComputeContext context, ReadOnlySpan message)
+ {
+ ref CommandList commandList = ref ComputeContext.GetCommandList(in context, pipelineState: null);
+
+ commandList.D3D12GraphicsCommandList->SetPixMarkerUnsafe(0, message);
+ }
+}
diff --git a/src/ComputeSharp.Pix/ComputeSharp.Pix.csproj b/src/ComputeSharp.Pix/ComputeSharp.Pix.csproj
new file mode 100644
index 00000000..1ad34cdb
--- /dev/null
+++ b/src/ComputeSharp.Pix/ComputeSharp.Pix.csproj
@@ -0,0 +1,70 @@
+
+
+ netstandard2.0;net6.0
+ bin\Release
+ ComputeSharp.Pix.xml
+ AnyCPU;x64;ARM64
+
+
+
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ winpixeventruntime.1.0.220124001
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ComputeSharp.Pix/ComputeSharp.Pix.targets b/src/ComputeSharp.Pix/ComputeSharp.Pix.targets
new file mode 100644
index 00000000..311809be
--- /dev/null
+++ b/src/ComputeSharp.Pix/ComputeSharp.Pix.targets
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+ winpixeventruntime.1.0.220124001
+
+
+ false
+ true
+
+
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ComputeSharp.Pix/Interop/ID3D12GraphicsCommandListExtensions.cs b/src/ComputeSharp.Pix/Interop/ID3D12GraphicsCommandListExtensions.cs
new file mode 100644
index 00000000..816128a2
--- /dev/null
+++ b/src/ComputeSharp.Pix/Interop/ID3D12GraphicsCommandListExtensions.cs
@@ -0,0 +1,105 @@
+using System;
+using System.Buffers;
+using System.Runtime.CompilerServices;
+using System.Text;
+using TerraFX.Interop.DirectX;
+
+namespace ComputeSharp.Interop;
+
+///
+/// A with extensions for the type.
+///
+internal static class ID3D12GraphicsCommandListExtensions
+{
+ ///
+ /// Begins a PIX event on a target object.
+ ///
+ /// The target object.
+ /// The color to use for the event.
+ /// The message to use for the event.
+ public static unsafe void BeginEvent(this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, uint color, string message)
+ {
+ // Rent a byte buffer with space for the null-terminator too
+ int maxByteLength = Encoding.ASCII.GetMaxByteCount(message.Length) + 1;
+ byte[] buffer = ArrayPool.Shared.Rent(maxByteLength);
+ int bytesWritten;
+
+ fixed (byte* bufferPtr = buffer)
+ {
+ // Transcode from unicode to ASCII
+ fixed (char* messagePtr = message)
+ {
+ bytesWritten = Encoding.ASCII.GetBytes(messagePtr, message.Length, bufferPtr, buffer.Length);
+ }
+
+ // Add the null terminator
+ buffer[bytesWritten] = 0;
+
+ // Write the marker with the null-terminated ANSI message
+ Pix.PIXBeginEventOnCommandList((ID3D12GraphicsCommandList*)Unsafe.AsPointer(ref d3D12GraphicsCommandList), color, (sbyte*)bufferPtr);
+ }
+
+ // Return the buffer (if an exception is thrown, it's fine to not do so)
+ ArrayPool.Shared.Return(buffer);
+ }
+
+ ///
+ /// Begins a PIX event on a target object.
+ ///
+ /// The target object.
+ /// The color to use for the event.
+ /// The message to use for the event (it's assumed to be a -terminated ANSI characters sequence).
+ public static unsafe void BeginEventUnsafe(this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, uint color, ReadOnlySpan message)
+ {
+ fixed (byte* messagePtr = message)
+ {
+ Pix.PIXBeginEventOnCommandList((ID3D12GraphicsCommandList*)Unsafe.AsPointer(ref d3D12GraphicsCommandList), color, (sbyte*)messagePtr);
+ }
+ }
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The target object.
+ /// The color to use for the marker.
+ /// The message to use for the marker.
+ public static unsafe void SetPixMarker(this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, uint color, string message)
+ {
+ // Rent a byte buffer with space for the null-terminator too
+ int maxByteLength = Encoding.ASCII.GetMaxByteCount(message.Length) + 1;
+ byte[] buffer = ArrayPool.Shared.Rent(maxByteLength);
+ int bytesWritten;
+
+ fixed (byte* bufferPtr = buffer)
+ {
+ // Transcode from unicode to ASCII
+ fixed (char* messagePtr = message)
+ {
+ bytesWritten = Encoding.ASCII.GetBytes(messagePtr, message.Length, bufferPtr, buffer.Length);
+ }
+
+ // Add the null terminator
+ buffer[bytesWritten] = 0;
+
+ // Write the marker with the null-terminated ANSI message
+ Pix.PIXSetMarkerOnCommandList((ID3D12GraphicsCommandList*)Unsafe.AsPointer(ref d3D12GraphicsCommandList), color, (sbyte*)bufferPtr);
+ }
+
+ // Return the buffer (if an exception is thrown, it's fine to not do so)
+ ArrayPool.Shared.Return(buffer);
+ }
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// The target object.
+ /// The color to use for the marker.
+ /// The message to use for the event (it's assumed to be a -terminated ANSI characters sequence).
+ public static unsafe void SetPixMarkerUnsafe(this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, uint color, ReadOnlySpan message)
+ {
+ fixed (byte* messagePtr = message)
+ {
+ Pix.PIXSetMarkerOnCommandList((ID3D12GraphicsCommandList*)Unsafe.AsPointer(ref d3D12GraphicsCommandList), color, (sbyte*)messagePtr);
+ }
+ }
+}
diff --git a/src/ComputeSharp.Pix/Interop/Pix.cs b/src/ComputeSharp.Pix/Interop/Pix.cs
new file mode 100644
index 00000000..cc6ee0bf
--- /dev/null
+++ b/src/ComputeSharp.Pix/Interop/Pix.cs
@@ -0,0 +1,44 @@
+using System.Runtime.InteropServices;
+using TerraFX.Interop.DirectX;
+
+namespace ComputeSharp.Interop;
+
+///
+/// A collection of native bindings for PIX APIs (see ).
+///
+internal static unsafe partial class Pix
+{
+ ///
+ /// Starts a PIX event on a target object.
+ ///
+ /// C export: typedef void(WINAPI* BeginEventOnCommandList)(ID3D12GraphicsCommandList* commandList, UINT64 color, _In_ PCSTR formatString).
+ ///
+ ///
+ /// The target object.
+ /// The color to use for the event.
+ /// The format string to use for the event (in ANSI format, -terminated).
+ [DllImport("WinPixEventRuntime", ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
+ public static extern void PIXBeginEventOnCommandList(ID3D12GraphicsCommandList* commandList, ulong color, sbyte* formatString);
+
+ ///
+ /// Ends a PIX event on a target object.
+ ///
+ /// C export: typedef void(WINAPI* EndEventOnCommandList)(ID3D12GraphicsCommandList* commandList).
+ ///
+ ///
+ /// The target object.
+ [DllImport("WinPixEventRuntime", ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
+ public static extern void PIXEndEventOnCommandList(ID3D12GraphicsCommandList* commandList);
+
+ ///
+ /// Sets a PIX marker on a target object.
+ ///
+ /// C export: typedef void(WINAPI* SetMarkerOnCommandList)(ID3D12GraphicsCommandList* commandList, UINT64 color, _In_ PCSTR formatString).
+ ///
+ ///
+ /// The target object.
+ /// The color to use for the marker.
+ /// The format string to use for the marker (in ANSI format, -terminated).
+ [DllImport("WinPixEventRuntime", ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
+ public static extern void PIXSetMarkerOnCommandList(ID3D12GraphicsCommandList* commandList, ulong color, sbyte* formatString);
+}
diff --git a/src/ComputeSharp.Pix/Interop/Pix.h.cs b/src/ComputeSharp.Pix/Interop/Pix.h.cs
new file mode 100644
index 00000000..3cca15bd
--- /dev/null
+++ b/src/ComputeSharp.Pix/Interop/Pix.h.cs
@@ -0,0 +1,43 @@
+/*==========================================================================;
+ *
+ * Copyright (C) Microsoft Corporation. All Rights Reserved.
+ *
+ * File: pix3.h
+ * Content: PIX include file
+ *
+ ****************************************************************************/
+
+// The following methods in this file have been ported from the
+// pix3.h file in the winpixeventruntime.1.0.220124001 package.
+
+using System.Runtime.CompilerServices;
+
+namespace ComputeSharp.Interop;
+
+///
+partial class Pix
+{
+ ///
+ /// Gets a value representing a color for a PIX event.
+ ///
+ /// The red channel value for the color.
+ /// The green channel value for the color.
+ /// The blue channel value for the color.
+ /// A value representing a color for a PIX event.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static uint PIX_COLOR(byte r, byte g, byte b)
+ {
+ return 0xFF000000 | ((uint)r << 16) | ((uint)g << 8) | b;
+ }
+
+ ///
+ /// Gets a value representing an indexed color for a PIX event.
+ ///
+ /// The index of the event to get the color for.
+ /// A value representing an indexed color for a PIX event.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static uint PIX_COLOR_INDEX(byte i)
+ {
+ return i;
+ }
+}
diff --git a/src/ComputeSharp.Pix/LICENSE.txt b/src/ComputeSharp.Pix/LICENSE.txt
new file mode 100644
index 00000000..548ece17
--- /dev/null
+++ b/src/ComputeSharp.Pix/LICENSE.txt
@@ -0,0 +1,106 @@
+MIT License
+
+Copyright (c) 2022 Sergio Pedri
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+This project incorporates components from PIX on Windows (https://devblogs.microsoft.com/pix/winpixeventruntime/).
+
+%% PIX on Windows NOTICES AND INFORMATION BEGIN HERE
+=========================================
+MICROSOFT SOFTWARE LICENSE TERMS
+
+PIX EVENT RUNTIME FOR WINDOWS
+
+IF YOU LIVE IN (OR ARE A BUSINESS WITH A PRINCIPAL PLACE OF BUSINESS IN) THE UNITED STATES, PLEASE READ THE “BINDING ARBITRATION AND CLASS ACTION WAIVER” SECTION BELOW. IT AFFECTS HOW DISPUTES ARE RESOLVED.
+
+These license terms are an agreement between you and Microsoft Corporation (or one of its affiliates). They apply to the software named above and any Microsoft services or software updates (except to the extent such services or updates are accompanied by new or additional terms, in which case those different terms apply prospectively and do not alter your or Microsoft’s rights relating to pre-updated software or services). IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS.
+
+1. INSTALLATION AND USE RIGHTS.
+ a. General. You may install and use any number of copies of the software to design, develop and test your Microsoft Windows programs.
+ b. Third Party Software. The software may include third party applications that are licensed to you under this agreement or under their own terms. License terms, notices, and acknowledgements, if any, for the third party applications may be accessible online at http://aka.ms/thirdpartynotices or in an accompanying notices file. Even if such applications are governed by other agreements, the disclaimer, limitations on, and exclusions of damages below also apply to the extent allowed by applicable law.
+
+2. DISTRIBUTABLE CODE.
+ a. Distributable Code. The software is comprised of Distributable Code. “Distributable Code” is code that you are permitted to distribute in programs you develop if you comply with the terms below.
+ (i) Right to Use and Distribute.
+ * You may copy and distribute the object code form of the software.
+ * Third Party Distribution. You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs.
+ (ii) Distribution Requirements. For any Distributable Code you distribute, you must
+ * add significant primary functionality to it in your programs;
+ * require distributors and external end users to agree to terms that protect it at least as much as this agreement;
+ * display your valid copyright notice on your programs; and
+ * indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your programs.
+ (iii) Distribution Restrictions. You may not
+ * alter any copyright, trademark or patent notice in the Distributable Code;
+ * use Microsoft’s trademarks in your programs’ names or in a way that suggests your programs come from or are endorsed by Microsoft;
+ * distribute Distributable Code to run on a platform other than a Windows platform;
+ * include Distributable Code in malicious, deceptive or unlawful programs; or
+ * modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a condition of use, modification or distribution, that
+ * the code be disclosed or distributed in source code form; or
+ * others have the right to modify it.
+
+3. SCOPE OF LICENSE. The software is licensed, not sold. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you will not (and have no right to):
+ a. work around any technical limitations in the software that only allow you to use it in certain ways;
+ b. reverse engineer, decompile or disassemble the software;
+ c. remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software;
+ d. use the software in any way that is against the law or to create or propagate malware; or
+ e. share, publish, distribute, or lend the software, provide the software as a stand-alone hosted solution for others to use, or transfer the software or this agreement to any third party.
+
+4. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit http://aka.ms/exporting.
+
+5. SUPPORT SERVICES. Microsoft is not obligated under this agreement to provide any support services for the software. Any support provided is “as is”, “with all faults”, and without warranty of any kind.
+
+6. BINDING ARBITRATION AND CLASS ACTION WAIVER. This Section applies if you live in (or, if a business, your principal place of business is in) the United States. If you and Microsoft have a dispute, you and Microsoft agree to try for 60 days to resolve it informally. If you and Microsoft can’t, you and Microsoft agree to binding individual arbitration before the American Arbitration Association under the Federal Arbitration Act (“FAA”), and not to sue in court in front of a judge or jury. Instead, a neutral arbitrator will decide. Class action lawsuits, class-wide arbitrations, private attorney-general actions, and any other proceeding where someone acts in a representative capacity are not allowed; nor is combining individual proceedings without the consent of all parties. The complete Arbitration Agreement contains more terms and is at http://aka.ms/arb-agreement-1. You and Microsoft agree to these terms.
+
+7. ENTIRE AGREEMENT. This agreement, and any other terms Microsoft may provide for supplements, updates, or third-party applications, is the entire agreement for the software.
+
+8. APPLICABLE LAW AND PLACE TO RESOLVE DISPUTES. If you acquired the software in the United States or Canada, the laws of the state or province where you live (or, if a business, where your principal place of business is located) govern the interpretation of this agreement, claims for its breach, and all other claims (including consumer protection, unfair competition, and tort claims), regardless of conflict of laws principles, except that the FAA governs everything related to arbitration. If you acquired the software in any other country, its laws apply, except that the FAA governs everything related to arbitration. If U.S. federal jurisdiction exists, you and Microsoft consent to exclusive jurisdiction and venue in the federal court in King County, Washington for all disputes heard in court (excluding arbitration). If not, you and Microsoft consent to exclusive jurisdiction and venue in the Superior Court of King County, Washington for all disputes heard in court (excluding arbitration).
+
+9. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state, province, or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state, province, or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you:
+ a. Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights.
+ b. Canada. If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software.
+ c. Germany and Austria.
+ (i) Warranty. The properly licensed software will perform substantially as described in any Microsoft materials that accompany the software. However, Microsoft gives no contractual guarantee in relation to the licensed software.
+ (ii) Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as, in case of death or personal or physical injury, Microsoft is liable according to the statutory law.
+ Subject to the foregoing clause (ii), Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence.
+
+10. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO THE EXTENT PERMITTED UNDER APPLICABLE LAWS, MICROSOFT EXCLUDES ALL IMPLIED WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+
+11. LIMITATION ON AND EXCLUSION OF DAMAGES. IF YOU HAVE ANY BASIS FOR RECOVERING DAMAGES DESPITE THE PRECEDING DISCLAIMER OF WARRANTY, YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.
+This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, warranty, guarantee, or condition; strict liability, negligence, or other tort; or any other claim; in each case to the extent permitted by applicable law.
+It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state, province, or country may not allow the exclusion or limitation of incidental, consequential, or other damages.
+
+
+[Please note: As this software is distributed in Canada, some of the clauses in this agreement are provided below in French.
+
+Remarque: Ce logiciel étant distribué au Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français.
+
+EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « tel quel ». Toute utilisation de ce logiciel est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues.
+
+LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices.
+
+Cette limitation concerne:
+ * tout ce qui est relié au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers; et
+ * les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur.
+
+Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage. Si votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera pas à votre égard.
+
+EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre pays si celles-ci ne le permettent pas.]
+=========================================
+END OF PIX on Windows NOTICES AND INFORMATION
\ No newline at end of file
diff --git a/src/ComputeSharp.Pix/Libraries/arm64/WinPixEventRuntime.dll b/src/ComputeSharp.Pix/Libraries/arm64/WinPixEventRuntime.dll
new file mode 100644
index 00000000..0f2d171f
Binary files /dev/null and b/src/ComputeSharp.Pix/Libraries/arm64/WinPixEventRuntime.dll differ
diff --git a/src/ComputeSharp.Pix/Libraries/arm64/WinPixEventRuntime_UAP.dll b/src/ComputeSharp.Pix/Libraries/arm64/WinPixEventRuntime_UAP.dll
new file mode 100644
index 00000000..bad0fdd5
Binary files /dev/null and b/src/ComputeSharp.Pix/Libraries/arm64/WinPixEventRuntime_UAP.dll differ
diff --git a/src/ComputeSharp.Pix/Libraries/x64/WinPixEventRuntime.dll b/src/ComputeSharp.Pix/Libraries/x64/WinPixEventRuntime.dll
new file mode 100644
index 00000000..85069167
Binary files /dev/null and b/src/ComputeSharp.Pix/Libraries/x64/WinPixEventRuntime.dll differ
diff --git a/src/ComputeSharp.Pix/Libraries/x64/WinPixEventRuntime_UAP.dll b/src/ComputeSharp.Pix/Libraries/x64/WinPixEventRuntime_UAP.dll
new file mode 100644
index 00000000..65b22124
Binary files /dev/null and b/src/ComputeSharp.Pix/Libraries/x64/WinPixEventRuntime_UAP.dll differ
diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs
index a22fb426..93b62925 100644
--- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs
+++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs
@@ -7,7 +7,7 @@ using static ComputeSharp.SourceGenerators.Diagnostics.DiagnosticDescriptors;
namespace ComputeSharp.SourceGenerators.SyntaxRewriters;
///
-internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
+partial class HlslSourceRewriter : CSharpSyntaxRewriter
{
///
public override SyntaxNode? VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpressionSyntax node)
diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs
index 835faaca..66417e4d 100644
--- a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs
+++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs
@@ -483,13 +483,13 @@ internal sealed unsafe partial class SwapChainManager : NativeObject
///
private unsafe partial void OnGetDynamicResolutionManager(out DynamicResolutionManager resolutionManager)
{
- using ComPtr dxgiFactory4 = default;
+ using ComPtr dxgiFactory6 = default;
- DeviceHelper.CreateDXGIFactory4(dxgiFactory4.GetAddressOf());
+ DeviceHelper.CreateDXGIFactory6(dxgiFactory6.GetAddressOf());
using ComPtr dxgiAdapter = default;
- dxgiFactory4.Get()->EnumAdapters(0, dxgiAdapter.GetAddressOf()).Assert();
+ dxgiFactory6.Get()->EnumAdapters(0, dxgiAdapter.GetAddressOf()).Assert();
int targetFramerate = dxgiAdapter.Get()->GetCompositionRefreshRate(DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM);
diff --git a/src/ComputeSharp/ComputeSharp.targets b/src/ComputeSharp/ComputeSharp.targets
index 971097ad..e2fa4629 100644
--- a/src/ComputeSharp/ComputeSharp.targets
+++ b/src/ComputeSharp/ComputeSharp.targets
@@ -18,27 +18,27 @@
the same version) but Microsoft.Build.Tasks.CodeAnalysis.dll is where MSBuild loads the compiler tasks from so if
someone is getting creative with msbuild tasks/targets this is the "most correct" assembly to check. -->
-
+
- @(CurrentCompilerAssemblyIdentity->'%(Version)')
+ @(ComputeSharpCurrentCompilerAssemblyIdentity->'%(Version)')
- true
+ true
-
+
-
+
diff --git a/src/ComputeSharp/Core/Dispatch/ThreadIds.Normalized.cs b/src/ComputeSharp/Core/Dispatch/ThreadIds.Normalized.cs
index 602258e3..75023d16 100644
--- a/src/ComputeSharp/Core/Dispatch/ThreadIds.Normalized.cs
+++ b/src/ComputeSharp/Core/Dispatch/ThreadIds.Normalized.cs
@@ -3,7 +3,7 @@
namespace ComputeSharp;
///
-public static partial class ThreadIds
+partial class ThreadIds
{
///
/// A that indicates the normalized ids of a given GPU thread running a compute shader.
diff --git a/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Resources.cs b/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Resources.cs
index e1c65de6..a434df13 100644
--- a/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Resources.cs
+++ b/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Resources.cs
@@ -7,7 +7,7 @@ using ComputeSharp.Resources;
namespace ComputeSharp;
///
-public static partial class GraphicsDeviceExtensions
+partial class GraphicsDeviceExtensions
{
///
/// Allocates a new constant buffer with the specified parameters.
diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12ResourceExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12ResourceExtensions.cs
index 3d46e96e..fdca3723 100644
--- a/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12ResourceExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/Interop/ID3D12ResourceExtensions.cs
@@ -17,6 +17,7 @@ internal static unsafe class ID3D12ResourceExtensions
///
/// The target to map.
/// A instance representing the mapped resource.
+ /// Thrown when the mapping operation fails.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ID3D12ResourceMap Map(this ref ID3D12Resource d3D12Resource)
{
@@ -32,7 +33,6 @@ internal static unsafe class ID3D12ResourceExtensions
///
/// The target to map.
/// A pointer to the mapped area for .
- /// Thrown when the mapping operation fails.
/// Only use this method to unmap resources that were mapped with .
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Unmap(this ref ID3D12Resource d3D12Resource)
@@ -43,9 +43,8 @@ internal static unsafe class ID3D12ResourceExtensions
///
/// Assigns a name to a given .
///
- /// The target to map.
+ /// The target to set the name for.
/// The wrapper object to get the name from.
- /// Thrown when the mapping operation fails.
[Conditional("DEBUG")]
public static void SetName(this ref ID3D12Resource d3D12Resource, object wrapper)
{
diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs
index ee8772d1..76c15576 100644
--- a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs
+++ b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs
@@ -21,7 +21,7 @@ using UnmanagedCallersOnlyAttribute = ComputeSharp.NetStandard.System.Runtime.In
namespace ComputeSharp.Graphics.Extensions;
///
-internal static unsafe partial class IWICStreamExtensions
+unsafe partial class IWICStreamExtensions
{
///
/// Initializes an input wrapping a given instance.
diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs
index 795cc5d2..019ef47d 100644
--- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs
@@ -15,7 +15,7 @@ using static TerraFX.Interop.DirectX.DXGI_GPU_PREFERENCE;
namespace ComputeSharp.Graphics.Helpers;
///
-internal static partial class DeviceHelper
+partial class DeviceHelper
{
///
/// A custom query type that iterates through devices matching a given predicate.
diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs
index 95b02175..8445a801 100644
--- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs
@@ -6,7 +6,7 @@ using TerraFX.Interop.Windows;
namespace ComputeSharp.Graphics.Helpers;
///
-internal static partial class DeviceHelper
+partial class DeviceHelper
{
///
/// The local cache of instances that are currently usable.
diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs
index 2ceec2b1..6a818106 100644
--- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs
@@ -2,8 +2,10 @@
using System.Runtime.InteropServices;
using System.Text;
using CommunityToolkit.Diagnostics;
+using ComputeSharp.Core.Extensions;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
+using static TerraFX.Interop.DirectX.D3D12_MESSAGE_ID;
using static TerraFX.Interop.DirectX.D3D12_MESSAGE_SEVERITY;
#if NET6_0_OR_GREATER
using Enum = System.Enum;
@@ -14,8 +16,13 @@ using Enum = ComputeSharp.NetStandard.System.Enum;
namespace ComputeSharp.Graphics.Helpers;
///
-internal static partial class DeviceHelper
+partial class DeviceHelper
{
+ ///
+ /// A shared used from to create messages.
+ ///
+ private static StringBuilder? infoQueueMessageBuilder;
+
///
/// Flushes all the pending debug messages for all existing instances to the console/debugger.
/// It also checks whether or not there are any error messages being logged that didn't result in an actual crash yet.
@@ -27,7 +34,7 @@ internal static partial class DeviceHelper
lock (DevicesCache)
{
- StringBuilder builder = new(1024);
+ StringBuilder builder = infoQueueMessageBuilder ??= new(1024);
foreach (var pair in D3D12InfoQueueMap)
{
@@ -53,7 +60,106 @@ internal static partial class DeviceHelper
builder.AppendLine($"[Category]: {Enum.GetName(message->Category)}");
builder.AppendLine($"[Severity]: {Enum.GetName(message->Severity)}");
builder.AppendLine($"[ID]: {Enum.GetName(message->ID)}");
- builder.Append($"[Description]: \"{new string(message->pDescription)}\"");
+
+ bool isDeviceRemovedMessage = message->ID is D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_AT_FAULT or D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_POSSIBLY_AT_FAULT or D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT;
+
+ // Special handling for device removal messages
+ if (isDeviceRemovedMessage)
+ {
+ HRESULT result = device.D3D12Device->GetDeviceRemovedReason();
+
+ // If the device removal reason is available, also include that in the output message
+ if (result != S.S_OK)
+ {
+ string deviceRemovalReason = (int)result switch
+ {
+ DXGI.DXGI_ERROR_DEVICE_HUNG => nameof(DXGI.DXGI_ERROR_DEVICE_HUNG),
+ DXGI.DXGI_ERROR_DEVICE_REMOVED => nameof(DXGI.DXGI_ERROR_DEVICE_REMOVED),
+ DXGI.DXGI_ERROR_DEVICE_RESET => nameof(DXGI.DXGI_ERROR_DEVICE_RESET),
+ DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR => nameof(DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR),
+ DXGI.DXGI_ERROR_INVALID_CALL => nameof(DXGI.DXGI_ERROR_INVALID_CALL),
+ _ => ThrowHelper.ThrowArgumentOutOfRangeException("Invalid GetDeviceRemovedReason HRESULT.")
+ };
+
+ builder.AppendLine($"[Reason]: {deviceRemovalReason}");
+ }
+ }
+
+ // If DRED is enabled, also output the available auto breadcrumbs
+ if (isDeviceRemovedMessage && Configuration.IsDeviceRemovedExtendedDataEnabled)
+ {
+ builder.AppendLine($"[Description]: \"{new string(message->pDescription)}\"");
+
+ using ComPtr d3D12DeviceRemovedExtendedData = default;
+
+ // Get the DRED data
+ int hresult = device.D3D12Device->QueryInterface(
+ riid: Windows.__uuidof(),
+ ppvObject: d3D12DeviceRemovedExtendedData.GetVoidAddressOf());
+
+ if (hresult != S.S_OK)
+ {
+ ThrowHelper.ThrowWin32Exception(hresult);
+ }
+
+ D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1 d3D12DredAutoBreadcrumbsOutput;
+
+ // Get the auto breadcrumbs for the current event
+ hresult = d3D12DeviceRemovedExtendedData.Get()->GetAutoBreadcrumbsOutput1(&d3D12DredAutoBreadcrumbsOutput);
+
+ if (hresult != S.S_OK)
+ {
+ ThrowHelper.ThrowWin32Exception(hresult);
+ }
+
+ builder.AppendLine("[DRED breadcrumbs START] ===============================");
+
+ int breadcrumbNodeIndex = 0;
+
+ // Traverse all the auto breadcrumb nodes and print their contents
+ for (D3D12_AUTO_BREADCRUMB_NODE1* d3D12AutoBreadcrumbNode = d3D12DredAutoBreadcrumbsOutput.pHeadAutoBreadcrumbNode;
+ d3D12AutoBreadcrumbNode is not null;
+ d3D12AutoBreadcrumbNode = d3D12AutoBreadcrumbNode->pNext, breadcrumbNodeIndex++)
+ {
+ uint numberOfExecutedOps = *d3D12AutoBreadcrumbNode->pLastBreadcrumbValue;
+
+ // For each auto breadcrumb node, not all recorded breadcrumb have actually been executed. To reduce the verbosity of the
+ // output and only show the most relevant info, indicate how many breadcrumbs were recorded and how many were actually
+ // executed, but then only display the executed ones in the code below. This makes it easier to debug hangs for users.
+ builder.AppendLine($"[NODE #{breadcrumbNodeIndex}]: {d3D12AutoBreadcrumbNode->BreadcrumbCount} total breadcrumb(s), {numberOfExecutedOps} executed breadcrumb(s)");
+
+ uint contextIndex = 0;
+
+ for (uint commandIndex = 0; commandIndex < numberOfExecutedOps; commandIndex++)
+ {
+ // An D3D12_AUTO_BREADCRUMB_NODE1 object has two pointers:
+ // - pCommandHistory, pointing to the full list of available breadcrumbs.
+ // - pBreadcrumbContexts, pointing to the list of available contexts.
+ // Each context also has a field to indicate the index of the breadcrumb it belongs to. Since these indices are
+ // sorted in ascending order, the following code loops through the executed breadcrumbs and then only checks if
+ // the current index for the context list is within bounds, and if so, if the current context has a matching index.
+ // If that is the case, the context message is extracted and the index is incremented, otherwise just the opcode
+ // is added to the debug output. Essentially, this is somewhat similar to a merge algorithm for two ordered lists.
+ if (contextIndex < d3D12AutoBreadcrumbNode->BreadcrumbContextsCount &&
+ d3D12AutoBreadcrumbNode->pBreadcrumbContexts[contextIndex].BreadcrumbIndex == commandIndex)
+ {
+ string context = new((char*)d3D12AutoBreadcrumbNode->pBreadcrumbContexts[contextIndex++].pContextString);
+
+ builder.AppendLine($">> [OP #{commandIndex}]: {d3D12AutoBreadcrumbNode->pCommandHistory[commandIndex]}, \"{context}\"");
+ }
+ else
+ {
+ builder.AppendLine($">> [OP #{commandIndex}]: {d3D12AutoBreadcrumbNode->pCommandHistory[commandIndex]}");
+ }
+ }
+ }
+
+ builder.AppendLine("================================= [DRED breadcrumbs END]");
+ }
+ else
+ {
+ builder.Append($"[Description]: \"{new string(message->pDescription)}\"");
+ }
}
finally
{
@@ -69,29 +175,6 @@ internal static partial class DeviceHelper
}
queue->ClearStoredMessages();
-
- HRESULT result = device.D3D12Device->GetDeviceRemovedReason();
-
- if (result != S.S_OK)
- {
- string message = (int)result switch
- {
- DXGI.DXGI_ERROR_DEVICE_HUNG => nameof(DXGI.DXGI_ERROR_DEVICE_HUNG),
- DXGI.DXGI_ERROR_DEVICE_REMOVED => nameof(DXGI.DXGI_ERROR_DEVICE_REMOVED),
- DXGI.DXGI_ERROR_DEVICE_RESET => nameof(DXGI.DXGI_ERROR_DEVICE_RESET),
- DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR => nameof(DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR),
- DXGI.DXGI_ERROR_INVALID_CALL => nameof(DXGI.DXGI_ERROR_INVALID_CALL),
- _ => ThrowHelper.ThrowArgumentOutOfRangeException("Invalid GetDeviceRemovedReason HRESULT.")
- };
-
- builder.Clear();
- builder.AppendLine($"[D3D12 device \"{device}\" removed (HW: {device.IsHardwareAccelerated}, UMA: {device.IsCacheCoherentUMA})]");
- builder.AppendLine($"[Reason]: {message}");
-
- hasErrorsOrWarnings = true;
-
- Trace.WriteLine(builder);
- }
}
}
diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs
index ce5158bf..67c91793 100644
--- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs
+++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs
@@ -15,7 +15,7 @@ using UnmanagedCallersOnlyAttribute = ComputeSharp.NetStandard.System.Runtime.In
namespace ComputeSharp.Graphics.Helpers;
///
-internal static partial class DeviceHelper
+partial class DeviceHelper
{
///
/// The creation flags for instances.
@@ -27,33 +27,24 @@ internal static partial class DeviceHelper
Configuration.IsDebugOutputEnabled ? (uint)DXGI.DXGI_CREATE_FACTORY_DEBUG : 0;
#endif
- ///
- /// Creates a new instance to be used to enumerate devices.
- ///
- /// The resulting instance.
- internal static unsafe void CreateDXGIFactory4(IDXGIFactory4** dxgiFactory4)
- {
- if (Configuration.IsDebugOutputEnabled)
- {
- EnableDebugMode();
- }
-
- DirectX.CreateDXGIFactory2(IDXGIFactoryCreationFlags, Windows.__uuidof(), (void**)dxgiFactory4).Assert();
- }
-
///
/// Creates a new instance to be used to enumerate devices.
///
/// The resulting instance.
internal static unsafe void CreateDXGIFactory6(IDXGIFactory6** dxgiFactory6)
{
- using ComPtr dxgiFactory4 = default;
-
if (Configuration.IsDebugOutputEnabled)
{
EnableDebugMode();
}
+ if (Configuration.IsDeviceRemovedExtendedDataEnabled)
+ {
+ EnableDeviceRemovedExtendedDataConfiguration();
+ }
+
+ using ComPtr dxgiFactory4 = default;
+
DirectX.CreateDXGIFactory2(IDXGIFactoryCreationFlags, Windows.__uuidof(), dxgiFactory4.GetVoidAddressOf()).Assert();
HRESULT result = dxgiFactory4.CopyTo(dxgiFactory6);
@@ -94,6 +85,23 @@ internal static partial class DeviceHelper
}
}
+ ///
+ /// Enables the DRED settings are enabled (see ).
+ ///
+ private static unsafe void EnableDeviceRemovedExtendedDataConfiguration()
+ {
+ using ComPtr d3D12DeviceRemovedExtendedDataSettings = default;
+
+ DirectX.D3D12GetDebugInterface(
+ riid: Windows.__uuidof(),
+ ppvDebug: d3D12DeviceRemovedExtendedDataSettings.GetVoidAddressOf()).Assert();
+
+ // Enable the auto-breadcrumbs and page faults reporting
+ d3D12DeviceRemovedExtendedDataSettings.Get()->SetAutoBreadcrumbsEnablement(D3D12_DRED_ENABLEMENT.D3D12_DRED_ENABLEMENT_FORCED_ON);
+ d3D12DeviceRemovedExtendedDataSettings.Get()->SetBreadcrumbContextEnablement(D3D12_DRED_ENABLEMENT.D3D12_DRED_ENABLEMENT_FORCED_ON);
+ d3D12DeviceRemovedExtendedDataSettings.Get()->SetPageFaultEnablement(D3D12_DRED_ENABLEMENT.D3D12_DRED_ENABLEMENT_FORCED_ON);
+ }
+
///
/// A custom fallback implementation to use on systems with no support for it.
///
@@ -104,6 +112,10 @@ internal static partial class DeviceHelper
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate uint ReleaseDelegate(IDXGIFactory4As6Backcompat* @this);
+ ///
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate int EnumAdaptersDelegate(IDXGIFactory4As6Backcompat* @this, uint Adapter, IDXGIAdapter** ppAdapter);
+
///
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate int EnumWarpAdapterDelegate(IDXGIFactory4As6Backcompat* @this, Guid* riid, void** ppvAdapter);
@@ -117,6 +129,11 @@ internal static partial class DeviceHelper
///
private static readonly ReleaseDelegate ReleaseWrapper = Release;
+ ///
+ /// A cached instance wrapping .
+ ///
+ private static readonly EnumAdaptersDelegate EnumAdaptersWrapper = EnumAdapters;
+
///
/// A cached instance wrapping .
///
@@ -145,10 +162,12 @@ internal static partial class DeviceHelper
#if NET6_0_OR_GREATER
lpVtbl[2] = (delegate* unmanaged)&Release;
+ lpVtbl[7] = (delegate* unmanaged)&EnumAdapters;
lpVtbl[27] = (delegate* unmanaged)&EnumWarpAdapter;
lpVtbl[29] = (delegate* unmanaged)&EnumAdapterByGpuPreference;
#else
lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ReleaseWrapper);
+ lpVtbl[7] = (void*)Marshal.GetFunctionPointerForDelegate(EnumAdaptersWrapper);
lpVtbl[27] = (void*)Marshal.GetFunctionPointerForDelegate(EnumWarpAdapterWrapper);
lpVtbl[29] = (void*)Marshal.GetFunctionPointerForDelegate(EnumAdapterByGpuPreferenceWrapper);
#endif
@@ -194,6 +213,13 @@ internal static partial class DeviceHelper
return 0;
}
+ ///
+ [UnmanagedCallersOnly]
+ public static int EnumAdapters(IDXGIFactory4As6Backcompat* @this, uint Adapter, IDXGIAdapter** ppAdapter)
+ {
+ return @this->dxgiFactory4->EnumAdapters(Adapter, ppAdapter);
+ }
+
///
[UnmanagedCallersOnly]
public static int EnumWarpAdapter(IDXGIFactory4As6Backcompat* @this, Guid* riid, void** ppvAdapter)
diff --git a/src/ComputeSharp/Properties/AssemblyInfo.cs b/src/ComputeSharp/Properties/AssemblyInfo.cs
index 80e60132..2ef6928c 100644
--- a/src/ComputeSharp/Properties/AssemblyInfo.cs
+++ b/src/ComputeSharp/Properties/AssemblyInfo.cs
@@ -3,6 +3,7 @@
[module: SkipLocalsInit]
[assembly: InternalsVisibleTo("ComputeSharp.Dynamic")]
+[assembly: InternalsVisibleTo("ComputeSharp.Pix")]
[assembly: InternalsVisibleTo("ComputeSharp.Uwp")]
[assembly: InternalsVisibleTo("ComputeSharp.WinUI")]
diff --git a/src/ComputeSharp/Properties/Configuration.cs b/src/ComputeSharp/Properties/Configuration.cs
index ab805bcb..5907cfff 100644
--- a/src/ComputeSharp/Properties/Configuration.cs
+++ b/src/ComputeSharp/Properties/Configuration.cs
@@ -13,11 +13,21 @@ internal static class Configuration
///
private const string EnableDebugOutput = "COMPUTESHARP_ENABLE_DEBUG_OUTPUT";
+ ///
+ /// The configuration property name for .
+ ///
+ private const string EnableDeviceRemovedExtendedDataInfo = "COMPUTESHARP_ENABLE_DEVICE_REMOVED_EXTENDED_DATA";
+
///
/// Indicates whether or not the debug output is enabled.
///
public static readonly bool IsDebugOutputEnabled = GetConfigurationValue(EnableDebugOutput);
+ ///
+ /// Indicates whether or not the debug output is enabled.
+ ///
+ public static readonly bool IsDeviceRemovedExtendedDataEnabled = GetConfigurationValue(EnableDeviceRemovedExtendedDataInfo);
+
///
/// Gets a configuration value for a specified property.
///
diff --git a/src/ComputeSharp/Shaders/ComputeContext.cs b/src/ComputeSharp/Shaders/ComputeContext.cs
index fc3b0a40..46c03c31 100644
--- a/src/ComputeSharp/Shaders/ComputeContext.cs
+++ b/src/ComputeSharp/Shaders/ComputeContext.cs
@@ -81,7 +81,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
{
ThrowInvalidOperationExceptionIfDeviceIsNull();
- ref CommandList commandList = ref GetCommandList(in this, null);
+ ref CommandList commandList = ref GetCommandList(in this, pipelineState: null);
commandList.D3D12GraphicsCommandList->ClearUnorderedAccessView(d3D12Resource, d3D12GpuDescriptorHandle, d3D12CpuDescriptorHandle, isNormalized);
}
@@ -101,7 +101,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
{
ThrowInvalidOperationExceptionIfDeviceIsNull();
- ref CommandList commandList = ref GetCommandList(in this, null);
+ ref CommandList commandList = ref GetCommandList(in this, pipelineState: null);
commandList.D3D12GraphicsCommandList->FillUnorderedAccessView(d3D12Resource, d3D12GpuDescriptorHandle, d3D12CpuDescriptorHandle, value);
}
@@ -275,7 +275,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
{
ThrowInvalidOperationExceptionIfDeviceIsNull();
- ref CommandList commandList = ref GetCommandList(in this, null);
+ ref CommandList commandList = ref GetCommandList(in this, pipelineState: null);
commandList.D3D12GraphicsCommandList->TransitionBarrier(d3D12Resource, d3D12ResourceStatesBefore, d3D12ResourceStatesAfter);
}
@@ -345,7 +345,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
/// The input to load.
/// A reference to the instance to use.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static unsafe ref CommandList GetCommandList(in ComputeContext @this, ID3D12PipelineState* pipelineState)
+ internal static unsafe ref CommandList GetCommandList(in ComputeContext @this, ID3D12PipelineState* pipelineState)
{
ref ComputeContext context = ref Unsafe.AsRef(in @this);
diff --git a/src/TerraFX.Interop.Windows/DirectX/shared/dxgi1_6/IDXGIFactory6.cs b/src/TerraFX.Interop.Windows/DirectX/shared/dxgi1_6/IDXGIFactory6.cs
index 50c34e5e..e5674032 100644
--- a/src/TerraFX.Interop.Windows/DirectX/shared/dxgi1_6/IDXGIFactory6.cs
+++ b/src/TerraFX.Interop.Windows/DirectX/shared/dxgi1_6/IDXGIFactory6.cs
@@ -42,6 +42,13 @@ namespace TerraFX.Interop.DirectX
return ((delegate* unmanaged[Stdcall])(lpVtbl[2]))((IDXGIFactory6*)Unsafe.AsPointer(ref this));
}
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(7)]
+ public HRESULT EnumAdapters(uint Adapter, IDXGIAdapter** ppAdapter)
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[7]))((IDXGIFactory6*)Unsafe.AsPointer(ref this), Adapter, ppAdapter);
+ }
+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(24)]
public HRESULT CreateSwapChainForComposition(IUnknown* pDevice, [NativeTypeName("const DXGI_SWAP_CHAIN_DESC1 *")] DXGI_SWAP_CHAIN_DESC1* pDesc, IDXGIOutput* pRestrictToOutput, IDXGISwapChain1** ppSwapChain)
diff --git a/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_AUTO_BREADCRUMB_NODE1.cs b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_AUTO_BREADCRUMB_NODE1.cs
new file mode 100644
index 00000000..a5376c65
--- /dev/null
+++ b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_AUTO_BREADCRUMB_NODE1.cs
@@ -0,0 +1,36 @@
+// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
+
+// Ported from d3d12.h in Microsoft.Direct3D.D3D12 v1.600.10
+// Original source is Copyright © Microsoft. Licensed under the MIT license
+
+namespace TerraFX.Interop.DirectX
+{
+ internal unsafe partial struct D3D12_AUTO_BREADCRUMB_NODE1
+ {
+ [NativeTypeName("const char *")]
+ public sbyte* pCommandListDebugNameA;
+
+ [NativeTypeName("const wchar_t *")]
+ public ushort* pCommandListDebugNameW;
+
+ [NativeTypeName("const char *")]
+ public sbyte* pCommandQueueDebugNameA;
+
+ [NativeTypeName("const wchar_t *")]
+ public ushort* pCommandQueueDebugNameW;
+ public ID3D12GraphicsCommandList* pCommandList;
+ public ID3D12CommandQueue* pCommandQueue;
+ public uint BreadcrumbCount;
+
+ [NativeTypeName("const UINT *")]
+ public uint* pLastBreadcrumbValue;
+
+ [NativeTypeName("const D3D12_AUTO_BREADCRUMB_OP *")]
+ public D3D12_AUTO_BREADCRUMB_OP* pCommandHistory;
+
+ [NativeTypeName("const struct D3D12_AUTO_BREADCRUMB_NODE1 *")]
+ public D3D12_AUTO_BREADCRUMB_NODE1* pNext;
+ public uint BreadcrumbContextsCount;
+ public D3D12_DRED_BREADCRUMB_CONTEXT* pBreadcrumbContexts;
+ }
+}
\ No newline at end of file
diff --git a/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_AUTO_BREADCRUMB_OP.cs b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_AUTO_BREADCRUMB_OP.cs
new file mode 100644
index 00000000..95dd83ec
--- /dev/null
+++ b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_AUTO_BREADCRUMB_OP.cs
@@ -0,0 +1,56 @@
+// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
+
+// Ported from d3d12.h in Microsoft.Direct3D.D3D12 v1.600.10
+// Original source is Copyright © Microsoft. Licensed under the MIT license
+
+namespace TerraFX.Interop.DirectX
+{
+ internal enum D3D12_AUTO_BREADCRUMB_OP
+ {
+ D3D12_AUTO_BREADCRUMB_OP_SETMARKER = 0,
+ D3D12_AUTO_BREADCRUMB_OP_BEGINEVENT = 1,
+ D3D12_AUTO_BREADCRUMB_OP_ENDEVENT = 2,
+ D3D12_AUTO_BREADCRUMB_OP_DRAWINSTANCED = 3,
+ D3D12_AUTO_BREADCRUMB_OP_DRAWINDEXEDINSTANCED = 4,
+ D3D12_AUTO_BREADCRUMB_OP_EXECUTEINDIRECT = 5,
+ D3D12_AUTO_BREADCRUMB_OP_DISPATCH = 6,
+ D3D12_AUTO_BREADCRUMB_OP_COPYBUFFERREGION = 7,
+ D3D12_AUTO_BREADCRUMB_OP_COPYTEXTUREREGION = 8,
+ D3D12_AUTO_BREADCRUMB_OP_COPYRESOURCE = 9,
+ D3D12_AUTO_BREADCRUMB_OP_COPYTILES = 10,
+ D3D12_AUTO_BREADCRUMB_OP_RESOLVESUBRESOURCE = 11,
+ D3D12_AUTO_BREADCRUMB_OP_CLEARRENDERTARGETVIEW = 12,
+ D3D12_AUTO_BREADCRUMB_OP_CLEARUNORDEREDACCESSVIEW = 13,
+ D3D12_AUTO_BREADCRUMB_OP_CLEARDEPTHSTENCILVIEW = 14,
+ D3D12_AUTO_BREADCRUMB_OP_RESOURCEBARRIER = 15,
+ D3D12_AUTO_BREADCRUMB_OP_EXECUTEBUNDLE = 16,
+ D3D12_AUTO_BREADCRUMB_OP_PRESENT = 17,
+ D3D12_AUTO_BREADCRUMB_OP_RESOLVEQUERYDATA = 18,
+ D3D12_AUTO_BREADCRUMB_OP_BEGINSUBMISSION = 19,
+ D3D12_AUTO_BREADCRUMB_OP_ENDSUBMISSION = 20,
+ D3D12_AUTO_BREADCRUMB_OP_DECODEFRAME = 21,
+ D3D12_AUTO_BREADCRUMB_OP_PROCESSFRAMES = 22,
+ D3D12_AUTO_BREADCRUMB_OP_ATOMICCOPYBUFFERUINT = 23,
+ D3D12_AUTO_BREADCRUMB_OP_ATOMICCOPYBUFFERUINT64 = 24,
+ D3D12_AUTO_BREADCRUMB_OP_RESOLVESUBRESOURCEREGION = 25,
+ D3D12_AUTO_BREADCRUMB_OP_WRITEBUFFERIMMEDIATE = 26,
+ D3D12_AUTO_BREADCRUMB_OP_DECODEFRAME1 = 27,
+ D3D12_AUTO_BREADCRUMB_OP_SETPROTECTEDRESOURCESESSION = 28,
+ D3D12_AUTO_BREADCRUMB_OP_DECODEFRAME2 = 29,
+ D3D12_AUTO_BREADCRUMB_OP_PROCESSFRAMES1 = 30,
+ D3D12_AUTO_BREADCRUMB_OP_BUILDRAYTRACINGACCELERATIONSTRUCTURE = 31,
+ D3D12_AUTO_BREADCRUMB_OP_EMITRAYTRACINGACCELERATIONSTRUCTUREPOSTBUILDINFO = 32,
+ D3D12_AUTO_BREADCRUMB_OP_COPYRAYTRACINGACCELERATIONSTRUCTURE = 33,
+ D3D12_AUTO_BREADCRUMB_OP_DISPATCHRAYS = 34,
+ D3D12_AUTO_BREADCRUMB_OP_INITIALIZEMETACOMMAND = 35,
+ D3D12_AUTO_BREADCRUMB_OP_EXECUTEMETACOMMAND = 36,
+ D3D12_AUTO_BREADCRUMB_OP_ESTIMATEMOTION = 37,
+ D3D12_AUTO_BREADCRUMB_OP_RESOLVEMOTIONVECTORHEAP = 38,
+ D3D12_AUTO_BREADCRUMB_OP_SETPIPELINESTATE1 = 39,
+ D3D12_AUTO_BREADCRUMB_OP_INITIALIZEEXTENSIONCOMMAND = 40,
+ D3D12_AUTO_BREADCRUMB_OP_EXECUTEEXTENSIONCOMMAND = 41,
+ D3D12_AUTO_BREADCRUMB_OP_DISPATCHMESH = 42,
+ D3D12_AUTO_BREADCRUMB_OP_ENCODEFRAME = 43,
+ D3D12_AUTO_BREADCRUMB_OP_RESOLVEENCODEROUTPUTMETADATA = 44,
+ }
+}
\ No newline at end of file
diff --git a/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_DRED_AUTO_BREADCRUMB_OUTPUT1.cs b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_DRED_AUTO_BREADCRUMB_OUTPUT1.cs
new file mode 100644
index 00000000..57b9e182
--- /dev/null
+++ b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_DRED_AUTO_BREADCRUMB_OUTPUT1.cs
@@ -0,0 +1,13 @@
+// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
+
+// Ported from d3d12.h in Microsoft.Direct3D.D3D12 v1.600.10
+// Original source is Copyright © Microsoft. Licensed under the MIT license
+
+namespace TerraFX.Interop.DirectX
+{
+ internal unsafe partial struct D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1
+ {
+ [NativeTypeName("const D3D12_AUTO_BREADCRUMB_NODE1 *")]
+ public D3D12_AUTO_BREADCRUMB_NODE1* pHeadAutoBreadcrumbNode;
+ }
+}
\ No newline at end of file
diff --git a/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_DRED_BREADCRUMB_CONTEXT.cs b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_DRED_BREADCRUMB_CONTEXT.cs
new file mode 100644
index 00000000..bf5f8904
--- /dev/null
+++ b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_DRED_BREADCRUMB_CONTEXT.cs
@@ -0,0 +1,15 @@
+// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
+
+// Ported from d3d12.h in Microsoft.Direct3D.D3D12 v1.600.10
+// Original source is Copyright © Microsoft. Licensed under the MIT license
+
+namespace TerraFX.Interop.DirectX
+{
+ internal unsafe partial struct D3D12_DRED_BREADCRUMB_CONTEXT
+ {
+ public uint BreadcrumbIndex;
+
+ [NativeTypeName("const wchar_t *")]
+ public ushort* pContextString;
+ }
+}
\ No newline at end of file
diff --git a/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_DRED_ENABLEMENT.cs b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_DRED_ENABLEMENT.cs
new file mode 100644
index 00000000..d3fb1b22
--- /dev/null
+++ b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/D3D12_DRED_ENABLEMENT.cs
@@ -0,0 +1,14 @@
+// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
+
+// Ported from d3d12.h in Microsoft.Direct3D.D3D12 v1.600.10
+// Original source is Copyright © Microsoft. Licensed under the MIT license
+
+namespace TerraFX.Interop.DirectX
+{
+ internal enum D3D12_DRED_ENABLEMENT
+ {
+ D3D12_DRED_ENABLEMENT_SYSTEM_CONTROLLED = 0,
+ D3D12_DRED_ENABLEMENT_FORCED_OFF = 1,
+ D3D12_DRED_ENABLEMENT_FORCED_ON = 2,
+ }
+}
\ No newline at end of file
diff --git a/src/TerraFX.Interop.Windows/DirectX/um/d3d12/ID3D12DeviceRemovedExtendedData1.cs b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/ID3D12DeviceRemovedExtendedData1.cs
new file mode 100644
index 00000000..2e7d0d58
--- /dev/null
+++ b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/ID3D12DeviceRemovedExtendedData1.cs
@@ -0,0 +1,50 @@
+// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
+
+// Ported from d3d12.h in Microsoft.Direct3D.D3D12 v1.600.10
+// Original source is Copyright © Microsoft. Licensed under the MIT license
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using TerraFX.Interop.Windows;
+
+namespace TerraFX.Interop.DirectX
+{
+ [Guid("9727A022-CF1D-4DDA-9EBA-EFFA653FC506")]
+ [NativeTypeName("struct ID3D12DeviceRemovedExtendedData1 : ID3D12DeviceRemovedExtendedData")]
+ [NativeInheritance("ID3D12DeviceRemovedExtendedData")]
+ internal unsafe partial struct ID3D12DeviceRemovedExtendedData1
+ {
+ public void** lpVtbl;
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(0)]
+ public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[0]))((ID3D12DeviceRemovedExtendedData1*)Unsafe.AsPointer(ref this), riid, ppvObject);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(1)]
+ [return: NativeTypeName("ULONG")]
+ public uint AddRef()
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[1]))((ID3D12DeviceRemovedExtendedData1*)Unsafe.AsPointer(ref this));
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(2)]
+ [return: NativeTypeName("ULONG")]
+ public uint Release()
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[2]))((ID3D12DeviceRemovedExtendedData1*)Unsafe.AsPointer(ref this));
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(5)]
+ public HRESULT GetAutoBreadcrumbsOutput1(D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1* pOutput)
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[5]))((ID3D12DeviceRemovedExtendedData1*)Unsafe.AsPointer(ref this), pOutput);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/TerraFX.Interop.Windows/DirectX/um/d3d12/ID3D12DeviceRemovedExtendedDataSettings1.cs b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/ID3D12DeviceRemovedExtendedDataSettings1.cs
new file mode 100644
index 00000000..4843bac0
--- /dev/null
+++ b/src/TerraFX.Interop.Windows/DirectX/um/d3d12/ID3D12DeviceRemovedExtendedDataSettings1.cs
@@ -0,0 +1,62 @@
+// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
+
+// Ported from d3d12.h in Microsoft.Direct3D.D3D12 v1.600.10
+// Original source is Copyright © Microsoft. Licensed under the MIT license
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using TerraFX.Interop.Windows;
+
+namespace TerraFX.Interop.DirectX
+{
+ [Guid("DBD5AE51-3317-4F0A-ADF9-1D7CEDCAAE0B")]
+ [NativeTypeName("struct ID3D12DeviceRemovedExtendedDataSettings1 : ID3D12DeviceRemovedExtendedDataSettings")]
+ [NativeInheritance("ID3D12DeviceRemovedExtendedDataSettings")]
+ internal unsafe partial struct ID3D12DeviceRemovedExtendedDataSettings1
+ {
+ public void** lpVtbl;
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(0)]
+ public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[0]))((ID3D12DeviceRemovedExtendedDataSettings1*)Unsafe.AsPointer(ref this), riid, ppvObject);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(1)]
+ public uint AddRef()
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[1]))((ID3D12DeviceRemovedExtendedDataSettings1*)Unsafe.AsPointer(ref this));
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(2)]
+ public uint Release()
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[2]))((ID3D12DeviceRemovedExtendedDataSettings1*)Unsafe.AsPointer(ref this));
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(3)]
+ public void SetAutoBreadcrumbsEnablement(D3D12_DRED_ENABLEMENT Enablement)
+ {
+ ((delegate* unmanaged[Stdcall])(lpVtbl[3]))((ID3D12DeviceRemovedExtendedDataSettings1*)Unsafe.AsPointer(ref this), Enablement);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(4)]
+ public void SetPageFaultEnablement(D3D12_DRED_ENABLEMENT Enablement)
+ {
+ ((delegate* unmanaged[Stdcall])(lpVtbl[4]))((ID3D12DeviceRemovedExtendedDataSettings1*)Unsafe.AsPointer(ref this), Enablement);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(6)]
+ public void SetBreadcrumbContextEnablement(D3D12_DRED_ENABLEMENT Enablement)
+ {
+ ((delegate* unmanaged[Stdcall])(lpVtbl[6]))((ID3D12DeviceRemovedExtendedDataSettings1*)Unsafe.AsPointer(ref this), Enablement);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/TerraFX.Interop.Windows/TerraFX.Interop.Windows.projitems b/src/TerraFX.Interop.Windows/TerraFX.Interop.Windows.projitems
index 72e40d22..bbf1838f 100644
--- a/src/TerraFX.Interop.Windows/TerraFX.Interop.Windows.projitems
+++ b/src/TerraFX.Interop.Windows/TerraFX.Interop.Windows.projitems
@@ -72,6 +72,8 @@
+
+
@@ -98,6 +100,9 @@
+
+
+
@@ -188,6 +193,8 @@
+
+
diff --git a/samples/ComputeSharp.Sample.NuGet/ComputeSharp.Sample.NuGet.csproj b/tests/ComputeSharp.Dynamic.NuGet/ComputeSharp.Dynamic.NuGet.csproj
similarity index 82%
rename from samples/ComputeSharp.Sample.NuGet/ComputeSharp.Sample.NuGet.csproj
rename to tests/ComputeSharp.Dynamic.NuGet/ComputeSharp.Dynamic.NuGet.csproj
index f75aab80..37213757 100644
--- a/samples/ComputeSharp.Sample.NuGet/ComputeSharp.Sample.NuGet.csproj
+++ b/tests/ComputeSharp.Dynamic.NuGet/ComputeSharp.Dynamic.NuGet.csproj
@@ -12,6 +12,4 @@
-
-
diff --git a/tests/ComputeSharp.Dynamic.NuGet/Program.cs b/tests/ComputeSharp.Dynamic.NuGet/Program.cs
new file mode 100644
index 00000000..31b654f0
--- /dev/null
+++ b/tests/ComputeSharp.Dynamic.NuGet/Program.cs
@@ -0,0 +1,35 @@
+using System.Diagnostics;
+using System.Linq;
+using ComputeSharp;
+
+float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
+
+// Create the graphics buffer
+using ReadWriteBuffer gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
+
+// Run the shader
+GraphicsDevice.Default.For(100, new MultiplyByTwo(gpuBuffer));
+
+// Get the data back
+float[] result = gpuBuffer.ToArray();
+
+// Validate results
+for (int i = 0; i < array.Length; i++)
+{
+ Trace.Assert(result[i] == array[i] * 2);
+}
+
+///
+/// A sample kernel that requires dynamic compilation, as it's not precompiled.
+///
+[AutoConstructor]
+internal readonly partial struct MultiplyByTwo : IComputeShader
+{
+ public readonly ReadWriteBuffer buffer;
+
+ ///
+ public void Execute()
+ {
+ buffer[ThreadIds.X] *= 2;
+ }
+}
diff --git a/samples/ComputeSharp.Sample.NuGet/nuget.config b/tests/ComputeSharp.Dynamic.NuGet/nuget.config
similarity index 100%
rename from samples/ComputeSharp.Sample.NuGet/nuget.config
rename to tests/ComputeSharp.Dynamic.NuGet/nuget.config
diff --git a/tests/ComputeSharp.NuGet/ComputeSharp.NuGet.csproj b/tests/ComputeSharp.NuGet/ComputeSharp.NuGet.csproj
new file mode 100644
index 00000000..7bdf5213
--- /dev/null
+++ b/tests/ComputeSharp.NuGet/ComputeSharp.NuGet.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ net472;netcoreapp3.1;net6.0
+ AnyCPU;x64;ARM64
+
+
+
+
+
+
+
+
diff --git a/tests/ComputeSharp.NuGet/Program.cs b/tests/ComputeSharp.NuGet/Program.cs
new file mode 100644
index 00000000..591d80de
--- /dev/null
+++ b/tests/ComputeSharp.NuGet/Program.cs
@@ -0,0 +1,36 @@
+using System.Diagnostics;
+using System.Linq;
+using ComputeSharp;
+
+float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
+
+// Create the graphics buffer
+using ReadWriteBuffer gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
+
+// Run the shader
+GraphicsDevice.Default.For(100, new MultiplyByTwo(gpuBuffer));
+
+// Get the data back
+float[] result = gpuBuffer.ToArray();
+
+// Validate results
+for (int i = 0; i < array.Length; i++)
+{
+ Trace.Assert(result[i] == array[i] * 2);
+}
+
+///
+/// A sample kernel that is precompiled.
+///
+[EmbeddedBytecode(DispatchAxis.X)]
+[AutoConstructor]
+internal readonly partial struct MultiplyByTwo : IComputeShader
+{
+ public readonly ReadWriteBuffer buffer;
+
+ ///
+ public void Execute()
+ {
+ buffer[ThreadIds.X] *= 2;
+ }
+}
diff --git a/tests/ComputeSharp.NuGet/nuget.config b/tests/ComputeSharp.NuGet/nuget.config
new file mode 100644
index 00000000..995d3a62
--- /dev/null
+++ b/tests/ComputeSharp.NuGet/nuget.config
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/tests/ComputeSharp.Pix.NuGet/ComputeSharp.Pix.NuGet.csproj b/tests/ComputeSharp.Pix.NuGet/ComputeSharp.Pix.NuGet.csproj
new file mode 100644
index 00000000..5f156d64
--- /dev/null
+++ b/tests/ComputeSharp.Pix.NuGet/ComputeSharp.Pix.NuGet.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net472;netcoreapp3.1;net6.0
+ AnyCPU;x64;ARM64
+
+
+
+
+
+
+
+
+
diff --git a/tests/ComputeSharp.Pix.NuGet/Program.cs b/tests/ComputeSharp.Pix.NuGet/Program.cs
new file mode 100644
index 00000000..c2119998
--- /dev/null
+++ b/tests/ComputeSharp.Pix.NuGet/Program.cs
@@ -0,0 +1,42 @@
+using System.Diagnostics;
+using System.Linq;
+using ComputeSharp;
+
+float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
+
+// Create the graphics buffer
+using ReadWriteBuffer gpuBuffer = GraphicsDevice.Default.AllocateReadWriteBuffer(array);
+
+// Run the shader
+using (var context = GraphicsDevice.Default.CreateComputeContext())
+{
+ context.Log("Dispatching shader");
+ context.BeginEvent("Dispatching event");
+ context.For(100, new MultiplyByTwo(gpuBuffer));
+ context.EndEvent();
+}
+
+// Get the data back
+float[] result = gpuBuffer.ToArray();
+
+// Validate results
+for (int i = 0; i < array.Length; i++)
+{
+ Trace.Assert(result[i] == array[i] * 2);
+}
+
+///
+/// A sample kernel that is precompiled.
+///
+[EmbeddedBytecode(DispatchAxis.X)]
+[AutoConstructor]
+internal readonly partial struct MultiplyByTwo : IComputeShader
+{
+ public readonly ReadWriteBuffer buffer;
+
+ ///
+ public void Execute()
+ {
+ buffer[ThreadIds.X] *= 2;
+ }
+}
diff --git a/tests/ComputeSharp.Pix.NuGet/nuget.config b/tests/ComputeSharp.Pix.NuGet/nuget.config
new file mode 100644
index 00000000..995d3a62
--- /dev/null
+++ b/tests/ComputeSharp.Pix.NuGet/nuget.config
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/ComputeSharp.Tests.NativeLibrariesResolver.csproj b/tests/ComputeSharp.Tests.NativeLibrariesResolver/ComputeSharp.Tests.NativeLibrariesResolver.csproj
index cb3020de..21bca770 100644
--- a/tests/ComputeSharp.Tests.NativeLibrariesResolver/ComputeSharp.Tests.NativeLibrariesResolver.csproj
+++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/ComputeSharp.Tests.NativeLibrariesResolver.csproj
@@ -11,4 +11,9 @@
+
+
+
+
+
diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/DynamicNativeLibrariesResolverTests.cs b/tests/ComputeSharp.Tests.NativeLibrariesResolver/DynamicNativeLibrariesResolverTests.cs
new file mode 100644
index 00000000..d990e218
--- /dev/null
+++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/DynamicNativeLibrariesResolverTests.cs
@@ -0,0 +1,37 @@
+using System.Diagnostics;
+using System.IO;
+using ComputeSharp.Tests.NativeLibrariesResolver.Helpers;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace ComputeSharp.Tests.NativeLibrariesResolver;
+
+[TestClass]
+public class DynamicNativeLibrariesResolverTests : NativeLibrariesResolverTestsBase
+{
+ ///
+ protected override string SampleProjectName => "ComputeSharp.Dynamic.NuGet";
+
+ ///
+ /// Performs static initialization for the assembly before any unit tests are run.
+ ///
+ /// The for the test runner instance in use.
+ [ClassInitialize]
+ public static void InitializeDynamicDependencies(TestContext _)
+ {
+ string path = Path.GetDirectoryName(typeof(DynamicNativeLibrariesResolverTests).Assembly.Location)!;
+
+ while (Path.GetFileName(path) is not "ComputeSharp")
+ {
+ path = Path.GetDirectoryName(path)!;
+ }
+
+ string corePackagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Core", "ComputeSharp.Core.msbuildproj");
+ string packagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Package", "ComputeSharp.Package.msbuildproj");
+ string dynamicPackagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Dynamic.Package", "ComputeSharp.Dynamic.Package.msbuildproj");
+
+ // Run dotnet pack and on the packaging projects, to ensure the local NuGet packages are available
+ Process.Start("dotnet", $"pack {corePackagingProjectPath} -c Release").WaitForExit();
+ Process.Start("dotnet", $"pack {packagingProjectPath} -c Release").WaitForExit();
+ Process.Start("dotnet", $"pack {dynamicPackagingProjectPath} -c Release").WaitForExit();
+ }
+}
diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs b/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs
new file mode 100644
index 00000000..503b491a
--- /dev/null
+++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs
@@ -0,0 +1,285 @@
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace ComputeSharp.Tests.NativeLibrariesResolver.Helpers;
+
+///
+/// A base class to implement native libraries tests.
+///
+public abstract class NativeLibrariesResolverTestsBase
+{
+ ///
+ /// Gets the name of the test project.
+ ///
+ protected abstract string SampleProjectName { get; }
+
+ ///
+ /// Gets the directory containing the current test project.
+ ///
+ private string SampleProjectDirectory
+ {
+ get
+ {
+ string path = Path.GetDirectoryName(typeof(NativeLibrariesResolverTestsBase).Assembly.Location)!;
+
+ while (Path.GetFileName(path) is not "tests")
+ {
+ path = Path.GetDirectoryName(path)!;
+ }
+
+ return Path.Combine(path, SampleProjectName);
+ }
+ }
+
+ [TestMethod]
+ [DataRow(Configuration.Debug, RID.None)]
+ [DataRow(Configuration.Debug, RID.Win_x64)]
+ [DataRow(Configuration.Release, RID.None)]
+ [DataRow(Configuration.Release, RID.Win_x64)]
+ public void DotnetRunWorks(Configuration configuration, RID rid)
+ {
+ CleanSampleProject(configuration, rid);
+
+ Assert.AreEqual(0, Exec(SampleProjectDirectory, "dotnet", $"run -c {configuration} -f net6.0 {ToOption(rid)}"));
+ }
+
+ [TestMethod]
+ [DataRow(Configuration.Debug, RID.None)]
+ [DataRow(Configuration.Debug, RID.Win_x64)]
+ [DataRow(Configuration.Release, RID.None)]
+ [DataRow(Configuration.Release, RID.Win_x64)]
+ public void DotnetBuildWithRunningDotnetHostFromProjectDirectoryWorks(Configuration configuration, RID rid)
+ {
+ CleanSampleProject(configuration, rid);
+ BuildSampleProject(configuration, rid);
+
+ string realtivePathToDll = Path.Combine("bin", $"{configuration}", "net6.0", $"{ToDirectory(rid)}", $"{SampleProjectName}.dll");
+
+ Assert.AreEqual(0, Exec(SampleProjectDirectory, "dotnet", realtivePathToDll));
+ }
+
+ [TestMethod]
+ [DataRow(Configuration.Debug, RID.None)]
+ [DataRow(Configuration.Debug, RID.Win_x64)]
+ [DataRow(Configuration.Release, RID.None)]
+ [DataRow(Configuration.Release, RID.Win_x64)]
+ public void DotnetBuildWithRunningDotnetHostDirectlyWorks(Configuration configuration, RID rid)
+ {
+ CleanSampleProject(configuration, rid);
+ BuildSampleProject(configuration, rid);
+
+ string pathToDllDirectory = Path.Combine(SampleProjectDirectory, "bin", $"{configuration}", "net6.0", $"{ToDirectory(rid)}");
+
+ Assert.AreEqual(0, Exec(pathToDllDirectory, "dotnet", $"{SampleProjectName}.dll"));
+ }
+
+ [TestMethod]
+ [DataRow(Configuration.Debug, RID.None)]
+ [DataRow(Configuration.Debug, RID.Win_x64)]
+ [DataRow(Configuration.Release, RID.None)]
+ [DataRow(Configuration.Release, RID.Win_x64)]
+ public void DotnetBuildWithRunningAppHostFromProjectDirectoryWorks(Configuration configuration, RID rid)
+ {
+ CleanSampleProject(configuration, rid);
+ BuildSampleProject(configuration, rid);
+
+ string relativePathToAppHost = Path.Combine("bin", $"{configuration}", "net6.0", $"{ToDirectory(rid)}", $"{SampleProjectName}.exe");
+
+ Assert.AreEqual(0, Exec(SampleProjectDirectory, relativePathToAppHost, ""));
+ }
+
+ [TestMethod]
+ [DataRow(Configuration.Debug, RID.None)]
+ [DataRow(Configuration.Debug, RID.Win_x64)]
+ [DataRow(Configuration.Release, RID.None)]
+ [DataRow(Configuration.Release, RID.Win_x64)]
+ public void DotnetBuildWithRunningAppHostDirectlyWorks(Configuration configuration, RID rid)
+ {
+ CleanSampleProject(configuration, rid);
+ BuildSampleProject(configuration, rid);
+
+ string pathToAppHostDirectory = Path.Combine(SampleProjectDirectory, "bin", $"{configuration}", "net6.0", $"{ToDirectory(rid)}");
+
+ Assert.AreEqual(0, Exec(pathToAppHostDirectory, $"{SampleProjectName}.exe", ""));
+ }
+
+
+ [TestMethod]
+ [DataRow(PublishMode.SelfContained, DeploymentMode.Multiassembly, NativeLibrariesDeploymentMode.NotApplicable)]
+ [DataRow(PublishMode.FrameworkDependent, DeploymentMode.Multiassembly, NativeLibrariesDeploymentMode.NotApplicable)]
+ [DataRow(PublishMode.SelfContained, DeploymentMode.SingleFile, NativeLibrariesDeploymentMode.CopyToApplicationDirectory)]
+ [DataRow(PublishMode.SelfContained, DeploymentMode.SingleFile, NativeLibrariesDeploymentMode.ExtractToTemporaryDirectory)]
+ [DataRow(PublishMode.FrameworkDependent, DeploymentMode.SingleFile, NativeLibrariesDeploymentMode.CopyToApplicationDirectory)]
+ [DataRow(PublishMode.FrameworkDependent, DeploymentMode.SingleFile, NativeLibrariesDeploymentMode.ExtractToTemporaryDirectory)]
+ public void DotnetPublishWorks(PublishMode publishMode, DeploymentMode deploymentMode, NativeLibrariesDeploymentMode nativeLibsDeploymentMode)
+ {
+ // Publishing without specifying a RID is not supported.
+ // Furthermore, only publishing in Release mode is tested.
+ CleanSampleProject(Configuration.Release, RID.Win_x64);
+
+ Exec(SampleProjectDirectory, "dotnet", $"publish -c Release -f net6.0 -r win-x64 {ToOption(publishMode)} {ToOption(deploymentMode)} {ToOption(nativeLibsDeploymentMode)} /bl");
+
+ string pathToAppHost = Path.Combine("bin", $"Release", "net6.0", "win-x64", "publish", $"{SampleProjectName}.exe");
+
+ Assert.AreEqual(0, Exec(SampleProjectDirectory, pathToAppHost, ""));
+ }
+
+ ///
+ /// Cleans the sample project's artifacts for a specific configuration and target runtime.
+ /// This method is called at the start of each test method to work around bugs around some up-to-date checks
+ /// Causing certain targets to not run and effectively corrupting the build output.
+ ///
+ /// The configuration for which the output is cleaned.
+ /// The RID for which the output is cleaned.
+ private void CleanSampleProject(Configuration configuration, RID rid)
+ {
+ Exec(SampleProjectDirectory, "dotnet", $"clean -c {configuration} {ToOption(rid)}");
+ }
+
+ ///
+ /// Builds the sample project with a specific configuration and target runtime.
+ ///
+ /// The configuration to use to build the project.
+ /// The RID to use to build the project.
+ private void BuildSampleProject(Configuration configuration, RID rid)
+ {
+ Exec(SampleProjectDirectory, "dotnet", $"build -c {configuration} {ToOption(rid)}");
+ }
+
+ ///
+ /// Executes a specified process from the command line and returns the exit code.
+ ///
+ /// The working directory to execute the process.
+ /// The target file path for the process to execute.
+ /// The arguments to invoke the process.
+ /// The exit code for the executed process.
+ private static int Exec(string workingDirectory, string filePath, string arguments)
+ {
+ ProcessStartInfo startInfo = new()
+ {
+ UseShellExecute = true,
+ CreateNoWindow = true,
+ WindowStyle = ProcessWindowStyle.Hidden,
+ FileName = filePath,
+ Arguments = arguments,
+ WorkingDirectory = workingDirectory
+ };
+
+ using Process process = Process.Start(startInfo)!;
+
+ process.WaitForExit();
+
+ return process.ExitCode;
+ }
+
+ ///
+ /// Gets a text representation of the command line argument for the given .
+ ///
+ /// The input value.
+ /// A text representation for .
+ private static string ToOption(RID rid) => rid switch
+ {
+ RID.None => "",
+ RID.Win_x64 => "-r win-x64",
+ _ => throw new InvalidEnumArgumentException(nameof(rid), (int)rid, typeof(RID))
+ };
+
+ ///
+ /// Gets a text representation of the command line argument for the given .
+ ///
+ /// The input value.
+ /// A text representation for .
+ private static string ToOption(PublishMode publishMode) => publishMode switch
+ {
+ PublishMode.FrameworkDependent => "--self-contained false",
+ PublishMode.SelfContained => "--self-contained true",
+ _ => throw new InvalidEnumArgumentException(nameof(publishMode), (int)publishMode, typeof(PublishMode))
+ };
+
+ ///
+ /// Gets a text representation of the command line argument for the given .
+ ///
+ /// The input value.
+ /// A text representation for .
+ private static string ToOption(DeploymentMode deploymentMode) => deploymentMode switch
+ {
+ DeploymentMode.Multiassembly => "/p:PublishSingleFile=false",
+ DeploymentMode.SingleFile => "/p:PublishSingleFile=true",
+ _ => throw new InvalidEnumArgumentException(nameof(deploymentMode), (int)deploymentMode, typeof(DeploymentMode))
+ };
+
+ ///
+ /// Gets a text representation of the command line argument for the given .
+ ///
+ /// The input value.
+ /// A text representation for .
+ private static string ToOption(NativeLibrariesDeploymentMode deploymentMode) => deploymentMode switch
+ {
+ NativeLibrariesDeploymentMode.NotApplicable => "",
+ NativeLibrariesDeploymentMode.CopyToApplicationDirectory => "/p:IncludeNativeLibrariesForSelfExtract=false",
+ NativeLibrariesDeploymentMode.ExtractToTemporaryDirectory => "/p:IncludeNativeLibrariesForSelfExtract=true",
+ _ => throw new InvalidEnumArgumentException(nameof(deploymentMode), (int)deploymentMode, typeof(NativeLibrariesDeploymentMode))
+ };
+
+ ///
+ /// Gets a text representation of the build folder for the given .
+ ///
+ /// The input value.
+ /// A text representation for .
+ private static string ToDirectory(RID rid) => rid switch
+ {
+ RID.None => "",
+ RID.Win_x64 => "win-x64",
+ _ => throw new InvalidEnumArgumentException(nameof(rid), (int)rid, typeof(RID))
+ };
+}
+
+///
+/// A build configuration.
+///
+public enum Configuration
+{
+ Debug,
+ Release
+}
+
+///
+/// A runtime identifier.
+///
+public enum RID
+{
+ None,
+ Win_x64
+}
+
+///
+/// Indicates how should the application carry the framework with itself.
+///
+public enum PublishMode
+{
+ FrameworkDependent,
+ SelfContained
+}
+
+///
+/// Indicates how should the application be packaged. Notably, these tests employ .NET 6 style SingleFile,
+/// aka SuperHost. It does not affect native libraries packaging in .NET 6, but may in the future.
+///
+public enum DeploymentMode
+{
+ Multiassembly,
+ SingleFile
+}
+
+///
+/// Indicates the deployment mode for application's native dependencies.
+/// Not applicable to multiassembly deployment mode.
+///
+public enum NativeLibrariesDeploymentMode
+{
+ NotApplicable,
+ ExtractToTemporaryDirectory,
+ CopyToApplicationDirectory
+}
\ No newline at end of file
diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs b/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs
index c949a9f3..6e8afe8c 100644
--- a/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs
+++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/NativeLibrariesResolverTests.cs
@@ -1,291 +1,35 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.ComponentModel;
-using System.Diagnostics;
+using System.Diagnostics;
using System.IO;
-
-[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)]
+using ComputeSharp.Tests.NativeLibrariesResolver.Helpers;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ComputeSharp.Tests.NativeLibrariesResolver;
[TestClass]
-public class NativeLibrariesResolverTests
+public class NativeLibrariesResolverTests : NativeLibrariesResolverTestsBase
{
+ ///
+ protected override string SampleProjectName => "ComputeSharp.NuGet";
+
///
/// Performs static initialization for the assembly before any unit tests are run.
///
/// The for the test runner instance in use.
- [AssemblyInitialize]
- public static void Initialize(TestContext _)
+ [ClassInitialize]
+ public static void InitializeDynamicDependencies(TestContext _)
{
- string path = Path.GetDirectoryName(typeof(NativeLibrariesResolverTests).Assembly.Location)!;
+ string path = Path.GetDirectoryName(typeof(DynamicNativeLibrariesResolverTests).Assembly.Location)!;
while (Path.GetFileName(path) is not "ComputeSharp")
{
path = Path.GetDirectoryName(path)!;
}
- SampleProjectDirectory = Path.Combine(path, "samples", "ComputeSharp.Sample.NuGet");
-
+ string corePackagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Core", "ComputeSharp.Core.msbuildproj");
string packagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Package", "ComputeSharp.Package.msbuildproj");
- string dynamicPackagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Dynamic.Package", "ComputeSharp.Dynamic.Package.msbuildproj");
// Run dotnet pack and on the packaging projects, to ensure the local NuGet packages are available
+ Process.Start("dotnet", $"pack {corePackagingProjectPath} -c Release").WaitForExit();
Process.Start("dotnet", $"pack {packagingProjectPath} -c Release").WaitForExit();
- Process.Start("dotnet", $"pack {dynamicPackagingProjectPath} -c Release").WaitForExit();
- }
-
- ///
- /// Gets the directory of the ComputeSharp.Sample.NuGet project.
- ///
- private static string? SampleProjectDirectory { get; set; }
-
- [TestMethod]
- [DataRow(Configuration.Debug, RID.None)]
- [DataRow(Configuration.Debug, RID.Win_x64)]
- [DataRow(Configuration.Release, RID.None)]
- [DataRow(Configuration.Release, RID.Win_x64)]
- public void DotnetRunWorks(Configuration configuration, RID rid)
- {
- CleanSampleProject(configuration, rid);
-
- Assert.AreEqual(0, Exec(SampleProjectDirectory!, "dotnet", $"run -c {configuration} -f net6.0 {ToOption(rid)}"));
- }
-
- [TestMethod]
- [DataRow(Configuration.Debug, RID.None)]
- [DataRow(Configuration.Debug, RID.Win_x64)]
- [DataRow(Configuration.Release, RID.None)]
- [DataRow(Configuration.Release, RID.Win_x64)]
- public void DotnetBuildWithRunningDotnetHostFromProjectDirectoryWorks(Configuration configuration, RID rid)
- {
- CleanSampleProject(configuration, rid);
- BuildSampleProject(configuration, rid);
-
- string realtivePathToDll = Path.Combine("bin", $"{configuration}", "net6.0", $"{ToDirectory(rid)}", "ComputeSharp.Sample.NuGet.dll");
-
- Assert.AreEqual(0, Exec(SampleProjectDirectory!, "dotnet", realtivePathToDll));
- }
-
- [TestMethod]
- [DataRow(Configuration.Debug, RID.None)]
- [DataRow(Configuration.Debug, RID.Win_x64)]
- [DataRow(Configuration.Release, RID.None)]
- [DataRow(Configuration.Release, RID.Win_x64)]
- public void DotnetBuildWithRunningDotnetHostDirectlyWorks(Configuration configuration, RID rid)
- {
- CleanSampleProject(configuration, rid);
- BuildSampleProject(configuration, rid);
-
- string pathToDllDirectory = Path.Combine(SampleProjectDirectory!, "bin", $"{configuration}", "net6.0", $"{ToDirectory(rid)}");
-
- Assert.AreEqual(0, Exec(pathToDllDirectory, "dotnet", "ComputeSharp.Sample.NuGet.dll"));
- }
-
- [TestMethod]
- [DataRow(Configuration.Debug, RID.None)]
- [DataRow(Configuration.Debug, RID.Win_x64)]
- [DataRow(Configuration.Release, RID.None)]
- [DataRow(Configuration.Release, RID.Win_x64)]
- public void DotnetBuildWithRunningAppHostFromProjectDirectoryWorks(Configuration configuration, RID rid)
- {
- CleanSampleProject(configuration, rid);
- BuildSampleProject(configuration, rid);
-
- string relativePathToAppHost = Path.Combine("bin", $"{configuration}", "net6.0", $"{ToDirectory(rid)}", "ComputeSharp.Sample.NuGet.exe");
-
- Assert.AreEqual(0, Exec(SampleProjectDirectory!, relativePathToAppHost, ""));
- }
-
- [TestMethod]
- [DataRow(Configuration.Debug, RID.None)]
- [DataRow(Configuration.Debug, RID.Win_x64)]
- [DataRow(Configuration.Release, RID.None)]
- [DataRow(Configuration.Release, RID.Win_x64)]
- public void DotnetBuildWithRunningAppHostDirectlyWorks(Configuration configuration, RID rid)
- {
- CleanSampleProject(configuration, rid);
- BuildSampleProject(configuration, rid);
-
- string pathToAppHostDirectory = Path.Combine(SampleProjectDirectory!, "bin", $"{configuration}", "net6.0", $"{ToDirectory(rid)}");
-
- Assert.AreEqual(0, Exec(pathToAppHostDirectory, "ComputeSharp.Sample.NuGet.exe", ""));
- }
-
-
- [TestMethod]
- [DataRow(PublishMode.SelfContained, DeploymentMode.Multiassembly, NativeLibrariesDeploymentMode.NotApplicable)]
- [DataRow(PublishMode.FrameworkDependent, DeploymentMode.Multiassembly, NativeLibrariesDeploymentMode.NotApplicable)]
- [DataRow(PublishMode.SelfContained, DeploymentMode.SingleFile, NativeLibrariesDeploymentMode.CopyToApplicationDirectory)]
- [DataRow(PublishMode.SelfContained, DeploymentMode.SingleFile, NativeLibrariesDeploymentMode.ExtractToTemporaryDirectory)]
- [DataRow(PublishMode.FrameworkDependent, DeploymentMode.SingleFile, NativeLibrariesDeploymentMode.CopyToApplicationDirectory)]
- [DataRow(PublishMode.FrameworkDependent, DeploymentMode.SingleFile, NativeLibrariesDeploymentMode.ExtractToTemporaryDirectory)]
- public void DotnetPublishWorks(PublishMode publishMode, DeploymentMode deploymentMode, NativeLibrariesDeploymentMode nativeLibsDeploymentMode)
- {
- // Publishing without specifying a RID is not supported.
- // Furthermore, only publishing in Release mode is tested.
- CleanSampleProject(Configuration.Release, RID.Win_x64);
-
- Exec(SampleProjectDirectory!, "dotnet", $"publish -c Release -f net6.0 -r win-x64 {ToOption(publishMode)} {ToOption(deploymentMode)} {ToOption(nativeLibsDeploymentMode)} /bl");
-
- string pathToAppHost = Path.Combine("bin", $"Release", "net6.0", "win-x64", "publish", "ComputeSharp.Sample.NuGet.exe");
-
- Assert.AreEqual(0, Exec(SampleProjectDirectory!, pathToAppHost, ""));
- }
-
- ///
- /// Cleans the sample project's artifacts for a specific configuration and target runtime.
- /// This method is called at the start of each test method to work around bugs around some up-to-date checks
- /// Causing certain targets to not run and effectively corrupting the build output.
- ///
- /// The configuration for which the output is cleaned.
- /// The RID for which the output is cleaned.
- private static void CleanSampleProject(Configuration configuration, RID rid)
- {
- Exec(SampleProjectDirectory!, "dotnet", $"clean -c {configuration} {ToOption(rid)}");
- }
-
- ///
- /// Builds the sample project with a specific configuration and target runtime.
- ///
- /// The configuration to use to build the project.
- /// The RID to use to build the project.
- private static void BuildSampleProject(Configuration configuration, RID rid)
- {
- Exec(SampleProjectDirectory!, "dotnet", $"build -c {configuration} {ToOption(rid)}");
- }
-
- ///
- /// Executes a specified process from the command line and returns the exit code.
- ///
- /// The working directory to execute the process.
- /// The target file path for the process to execute.
- /// The arguments to invoke the process.
- /// The exit code for the executed process.
- private static int Exec(string workingDirectory, string filePath, string arguments)
- {
- ProcessStartInfo startInfo = new()
- {
- UseShellExecute = true,
- CreateNoWindow = true,
- WindowStyle = ProcessWindowStyle.Hidden,
- FileName = filePath,
- Arguments = arguments,
- WorkingDirectory = workingDirectory
- };
-
- using Process process = Process.Start(startInfo)!;
-
- process.WaitForExit();
-
- return process.ExitCode;
- }
-
- ///
- /// Gets a text representation of the command line argument for the given .
- ///
- /// The input value.
- /// A text representation for .
- private static string ToOption(RID rid) => rid switch
- {
- RID.None => "",
- RID.Win_x64 => "-r win-x64",
- _ => throw new InvalidEnumArgumentException(nameof(rid), (int)rid, typeof(RID))
- };
-
- ///
- /// Gets a text representation of the command line argument for the given .
- ///
- /// The input value.
- /// A text representation for .
- private static string ToOption(PublishMode publishMode) => publishMode switch
- {
- PublishMode.FrameworkDependent => "--self-contained false",
- PublishMode.SelfContained => "--self-contained true",
- _ => throw new InvalidEnumArgumentException(nameof(publishMode), (int)publishMode, typeof(PublishMode))
- };
-
- ///
- /// Gets a text representation of the command line argument for the given .
- ///
- /// The input value.
- /// A text representation for .
- private static string ToOption(DeploymentMode deploymentMode) => deploymentMode switch
- {
- DeploymentMode.Multiassembly => "/p:PublishSingleFile=false",
- DeploymentMode.SingleFile => "/p:PublishSingleFile=true",
- _ => throw new InvalidEnumArgumentException(nameof(deploymentMode), (int)deploymentMode, typeof(DeploymentMode))
- };
-
- ///
- /// Gets a text representation of the command line argument for the given .
- ///
- /// The input value.
- /// A text representation for .
- private static string ToOption(NativeLibrariesDeploymentMode deploymentMode) => deploymentMode switch
- {
- NativeLibrariesDeploymentMode.NotApplicable => "",
- NativeLibrariesDeploymentMode.CopyToApplicationDirectory => "/p:IncludeNativeLibrariesForSelfExtract=false",
- NativeLibrariesDeploymentMode.ExtractToTemporaryDirectory => "/p:IncludeNativeLibrariesForSelfExtract=true",
- _ => throw new InvalidEnumArgumentException(nameof(deploymentMode), (int)deploymentMode, typeof(NativeLibrariesDeploymentMode))
- };
-
- ///
- /// Gets a text representation of the build folder for the given .
- ///
- /// The input value.
- /// A text representation for .
- private static string ToDirectory(RID rid) => rid switch
- {
- RID.None => "",
- RID.Win_x64 => "win-x64",
- _ => throw new InvalidEnumArgumentException(nameof(rid), (int)rid, typeof(RID))
- };
-
- ///
- /// A build configuration.
- ///
- public enum Configuration
- {
- Debug,
- Release
- }
-
- ///
- /// A runtime identifier.
- ///
- public enum RID
- {
- None,
- Win_x64
- }
-
- ///
- /// Indicates how should the application carry the framework with itself.
- ///
- public enum PublishMode
- {
- FrameworkDependent,
- SelfContained
- }
-
- ///
- /// Indicates how should the application be packaged. Notably, these tests employ .NET 6 style SingleFile,
- /// aka SuperHost. It does not affect native libraries packaging in .NET 6, but may in the future.
- ///
- public enum DeploymentMode
- {
- Multiassembly,
- SingleFile
- }
-
- ///
- /// Indicates the deployment mode for application's native dependencies.
- /// Not applicable to multiassembly deployment mode.
- ///
- public enum NativeLibrariesDeploymentMode
- {
- NotApplicable,
- ExtractToTemporaryDirectory,
- CopyToApplicationDirectory
}
}
diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/PixNativeLibrariesResolverTests.cs b/tests/ComputeSharp.Tests.NativeLibrariesResolver/PixNativeLibrariesResolverTests.cs
new file mode 100644
index 00000000..9624c1c4
--- /dev/null
+++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/PixNativeLibrariesResolverTests.cs
@@ -0,0 +1,37 @@
+using System.Diagnostics;
+using System.IO;
+using ComputeSharp.Tests.NativeLibrariesResolver.Helpers;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace ComputeSharp.Tests.NativeLibrariesResolver;
+
+[TestClass]
+public class PixNativeLibrariesResolverTests : NativeLibrariesResolverTestsBase
+{
+ ///
+ protected override string SampleProjectName => "ComputeSharp.Pix.NuGet";
+
+ ///
+ /// Performs static initialization for the assembly before any unit tests are run.
+ ///
+ /// The for the test runner instance in use.
+ [ClassInitialize]
+ public static void InitializeDynamicDependencies(TestContext _)
+ {
+ string path = Path.GetDirectoryName(typeof(PixNativeLibrariesResolverTests).Assembly.Location)!;
+
+ while (Path.GetFileName(path) is not "ComputeSharp")
+ {
+ path = Path.GetDirectoryName(path)!;
+ }
+
+ string corePackagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Core", "ComputeSharp.Core.msbuildproj");
+ string packagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Package", "ComputeSharp.Package.msbuildproj");
+ string pixPackagingProjectPath = Path.Combine(path, "src", "ComputeSharp.Pix.Package", "ComputeSharp.Pix.Package.msbuildproj");
+
+ // Run dotnet pack and on the packaging projects, to ensure the local NuGet packages are available
+ Process.Start("dotnet", $"pack {corePackagingProjectPath} -c Release").WaitForExit();
+ Process.Start("dotnet", $"pack {packagingProjectPath} -c Release").WaitForExit();
+ Process.Start("dotnet", $"pack {pixPackagingProjectPath} -c Release").WaitForExit();
+ }
+}
diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/Properties/AssemblyInfo.cs b/tests/ComputeSharp.Tests.NativeLibrariesResolver/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..6a076669
--- /dev/null
+++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/Properties/AssemblyInfo.cs
@@ -0,0 +1,3 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+[assembly: DoNotParallelize]
\ No newline at end of file