Merge pull request #179 from Sergio0694/feature/dynamic-library

Split runtime shader support to ComputeSharp.Dynamic
このコミットが含まれているのは:
Sergio Pedri authored and GitHub committed 2021-12-19 17:42:57 +01:00
コミット 30fea918cf
74ファイル変更
+750 -497

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

+21 -28
ファイルの表示
@@ -44,30 +44,10 @@ jobs:
run: msbuild -t:restore,build /p:Configuration=Release /p:Platform=x64
shell: cmd
# Build the whole ComputeSharp solution with /p:DisableShaderCompilationSupport=True
build-solution-release-no-dynamic:
runs-on: windows-2022
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Setup .NET Core 3.1 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Build
run: msbuild -t:restore,build /p:Configuration=Release /p:Platform=x64 /p:DisableShaderCompilationSupport=True
shell: cmd
# Run all the unit tests referencing the ComputeSharp project directly
run-tests:
if: success()
needs: [build-solution-debug, build-solution-release, build-solution-release-no-dynamic]
needs: [build-solution-debug, build-solution-release]
runs-on: windows-2022
steps:
- name: Git checkout
@@ -84,7 +64,7 @@ jobs:
run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.DisableDynamicCompilation (.NET 6)
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net6.0 /p:DisableShaderCompilationSupport=True -v n -l "console;verbosity=detailed"
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.Internals (.NET 6)
run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f net6.0 -v n -l "console;verbosity=detailed"
@@ -93,7 +73,7 @@ jobs:
run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.DisableDynamicCompilation (.NET Core 3.1)
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 /p:DisableShaderCompilationSupport=True -v n -l "console;verbosity=detailed"
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.Internals (.NET Core 3.1)
run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f netcoreapp3.1 /p:Platform=x64 -v n -l "console;verbosity=detailed"
@@ -102,7 +82,7 @@ jobs:
run: dotnet test tests\ComputeSharp.Tests\ComputeSharp.Tests.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.DisableDynamicCompilation (.NET Framework 4.7.2)
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net472 /p:Platform=x64 /p:DisableShaderCompilationSupport=True -v n -l "console;verbosity=detailed"
run: dotnet test tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed"
shell: cmd
- name: Run ComputeSharp.Tests.Internals (.NET Framework 4.7.2)
run: dotnet test tests\ComputeSharp.Tests.Internals\ComputeSharp.Tests.Internals.csproj -c Release -f net472 /p:Platform=x64 -v n -l "console;verbosity=detailed"
@@ -180,7 +160,7 @@ jobs:
# This workflow also uploads the resulting package as an artifact.
build-package:
if: success()
needs: [build-solution-debug, build-solution-release, build-solution-release-no-dynamic]
needs: [build-solution-debug, build-solution-release]
runs-on: windows-2022
steps:
- name: Git checkout
@@ -189,14 +169,22 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Build
- name: Build ComputeSharp package
run: dotnet build src\ComputeSharp.Package\ComputeSharp.Package.msbuildproj -c Release /p:ContinuousIntegrationBuild=True
shell: cmd
- name: Upload package artifact
- name: Upload ComputeSharp package artifact
uses: actions/upload-artifact@v2
with:
name: ComputeSharp.nupkg
path: src\ComputeSharp.Package\bin\Release\*.nupkg
- name: Build ComputeSharp.Dynamic package
run: dotnet build src\ComputeSharp.Dynamic.Package\ComputeSharp.Dynamic.Package.msbuildproj -c Release /p:ContinuousIntegrationBuild=True
shell: cmd
- name: Upload ComputeSharp.Dynamic package artifact
uses: actions/upload-artifact@v2
with:
name: ComputeSharp.Dynamic.nupkg
path: src\ComputeSharp.Dynamic.Package\bin\Release\*.nupkg
# Download the NuGet package generated in the previous job and use it
# to build and run the sample project referencing it. This is used as
@@ -215,11 +203,16 @@ jobs:
- name: Create local NuGet feed
run: mkdir src\ComputeSharp.Package\bin\Release
shell: cmd
- name: Download package artifact
- name: Download ComputeSharp package artifact
uses: actions/download-artifact@v2
with:
name: ComputeSharp.nupkg
path: src\ComputeSharp.Package\bin\Release\ComputeSharp.nupkg
- name: Download ComputeSharp.Dynamic package artifact
uses: actions/download-artifact@v2
with:
name: ComputeSharp.Dynamic.nupkg
path: src\ComputeSharp.Dynamic.Package\bin\Release\ComputeSharp.Dynamic.nupkg
- name: Build ComputeSharp.Sample.NuGet (.NET 6)
run: dotnet build samples\ComputeSharp.Sample.NuGet\ComputeSharp.Sample.NuGet.csproj -c Release -f net6.0
shell: cmd
+1
ファイルの表示
@@ -12,6 +12,7 @@
"samples\\ComputeSharp.SwapChain.Shaders.Shared\\ComputeSharp.SwapChain.Shaders.Shared.csproj",
"src\\ComputeSharp.SourceGenerators\\ComputeSharp.SourceGenerators.csproj",
"src\\ComputeSharp\\ComputeSharp.csproj",
"src\\ComputeSharp.Dynamic\\ComputeSharp.Dynamic.csproj",
"tests\\ComputeSharp.Tests.Internals\\ComputeSharp.Tests.Internals.csproj",
"tests\\ComputeSharp.Tests.NativeLibrariesResolver\\ComputeSharp.Tests.NativeLibrariesResolver.csproj",
"tests\\ComputeSharp.Tests.SourceGenerators\\ComputeSharp.Tests.SourceGenerators.csproj",
+33 -12
ファイルの表示
@@ -30,6 +30,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.SourceGenerato
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{FB17EF84-9208-47AC-921F-680CB1DAD8BA}"
ProjectSection(SolutionItems) = preProject
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.Package\icon.png = src\ComputeSharp.Package\icon.png
EndProjectSection
@@ -70,23 +71,30 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ComputeSharp.SwapChain.Core
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Tests.DisableDynamicCompilation", "tests\ComputeSharp.Tests.DisableDynamicCompilation\ComputeSharp.Tests.DisableDynamicCompilation.csproj", "{4A8FCE22-851C-442A-8BC9-3EC3FD00B637}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Dynamic", "src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj", "{76C66257-FDAA-47AB-85E7-EF757EAB10C0}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "TerraFX.Interop.Windows.Dynamic", "src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.shproj", "{158F984D-CD96-4062-BD02-2268946031A0}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
samples\ComputeSharp.SwapChain.Core.Shared\ComputeSharp.SwapChain.Core.Shared.projitems*{0071701e-b9c5-4098-be5f-ef556c4553c6}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{0071701e-b9c5-4098-be5f-ef556c4553c6}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{0800bd51-499d-44c2-9417-fd1f7fdfe9c4}*SharedItemsImports = 13
src\ComputeSharp.UI\ComputeSharp.UI.projitems*{0c82ede1-5b8a-4df3-87da-700b29d5e265}*SharedItemsImports = 13
src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems*{158f984d-cd96-4062-bd02-2268946031a0}*SharedItemsImports = 13
src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5
src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5
src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{514ff00e-bbf0-4d55-a47c-eeeb6208adce}*SharedItemsImports = 13
samples\ComputeSharp.Sample.Shared\ComputeSharp.Sample.Shared.projitems*{7048deea-0a6f-46a0-b951-b682a8f1cb75}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Core.Shared\ComputeSharp.SwapChain.Core.Shared.projitems*{751bb05b-563d-4b3a-94c6-15e2d79d35ea}*SharedItemsImports = 13
src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems*{76c66257-fdaa-47ab-85e7-ef757eab10c0}*SharedItemsImports = 5
samples\ComputeSharp.Sample.Shared\ComputeSharp.Sample.Shared.projitems*{8cefc324-ca6c-4845-9ad9-70b92bd87057}*SharedItemsImports = 13
src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{a5997814-d8d2-4541-87ac-c3e53caa67c0}*SharedItemsImports = 13
src\ComputeSharp.UI\ComputeSharp.UI.projitems*{afaafdc9-be42-45d4-8c79-0ee8c8edbf52}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{e7c9247d-016b-4819-af9f-0e9b3591e04b}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{e91f4d24-922a-4921-a8d7-9c45a143c45d}*SharedItemsImports = 5
src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5
src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5
src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5
src\ComputeSharp.UI\ComputeSharp.UI.projitems*{fa18ba9f-76bf-4de0-8d24-02fc7657e6cb}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Core.Shared\ComputeSharp.SwapChain.Core.Shared.projitems*{fbd388a5-7855-4408-98ff-e689f509db5a}*SharedItemsImports = 4
@@ -101,18 +109,18 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.ActiveCfg = Debug|x64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.Build.0 = Debug|x64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|ARM64.ActiveCfg = Debug|ARM64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|ARM64.Build.0 = Debug|ARM64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.ActiveCfg = Debug|x64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.Build.0 = Debug|x64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.ActiveCfg = Release|x64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.Build.0 = Release|x64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|ARM64.ActiveCfg = Release|ARM64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|ARM64.Build.0 = Release|ARM64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.ActiveCfg = Release|x64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.Build.0 = Release|x64
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|ARM64.Build.0 = Debug|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.ActiveCfg = Debug|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.Build.0 = Debug|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.Build.0 = Release|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|ARM64.ActiveCfg = Release|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|ARM64.Build.0 = Release|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.ActiveCfg = Release|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.Build.0 = Release|Any CPU
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|ARM64.ActiveCfg = Debug|Any CPU
@@ -317,6 +325,18 @@ Global
{4A8FCE22-851C-442A-8BC9-3EC3FD00B637}.Release|ARM64.Build.0 = Release|Any CPU
{4A8FCE22-851C-442A-8BC9-3EC3FD00B637}.Release|x64.ActiveCfg = Release|Any CPU
{4A8FCE22-851C-442A-8BC9-3EC3FD00B637}.Release|x64.Build.0 = Release|Any CPU
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Debug|Any CPU.ActiveCfg = Debug|x64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Debug|Any CPU.Build.0 = Debug|x64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Debug|ARM64.ActiveCfg = Debug|ARM64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Debug|ARM64.Build.0 = Debug|ARM64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Debug|x64.ActiveCfg = Debug|x64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Debug|x64.Build.0 = Debug|x64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Release|Any CPU.ActiveCfg = Release|x64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Release|Any CPU.Build.0 = Release|x64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Release|ARM64.ActiveCfg = Release|ARM64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Release|ARM64.Build.0 = Release|ARM64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Release|x64.ActiveCfg = Release|x64
{76C66257-FDAA-47AB-85E7-EF757EAB10C0}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -340,6 +360,7 @@ Global
{0800BD51-499D-44C2-9417-FD1F7FDFE9C4} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1}
{751BB05B-563D-4B3A-94C6-15E2D79D35EA} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1}
{4A8FCE22-851C-442A-8BC9-3EC3FD00B637} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
{158F984D-CD96-4062-BD02-2268946031A0} = {8DCE343F-BA78-4FE1-B562-B57C603A8BAA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4664C5E3-0340-4E22-BCFD-98AAEDF5F2DC}
+40 -4
ファイルの表示
@@ -1,5 +1,5 @@
![](https://user-images.githubusercontent.com/10199417/108635546-3512ea00-7480-11eb-8172-99bc59f4eb6f.png)
[![.NET](https://github.com/Sergio0694/ComputeSharp/workflows/.NET/badge.svg)](https://github.com/Sergio0694/ComputeSharp/actions) [![NuGet](https://img.shields.io/nuget/vpre/ComputeSharp.svg)](https://www.nuget.org/packages/ComputeSharp/) [![NuGet](https://img.shields.io/nuget/dt/ComputeSharp.svg)](https://www.nuget.org/stats/packages/ComputeSharp?groupby=Version)
[![.NET](https://github.com/Sergio0694/ComputeSharp/workflows/.NET/badge.svg)](https://github.com/Sergio0694/ComputeSharp/actions) [![NuGet](https://img.shields.io/nuget/dt/ComputeSharp.svg)](https://www.nuget.org/stats/packages/ComputeSharp?groupby=Version)
# What is it?
@@ -13,6 +13,7 @@ https://user-images.githubusercontent.com/10199417/126792509-c11feb11-a609-4fab-
# Table of Contents
- [Available packages](#available-packages)
- [Installing from NuGet](#installing-from-nuget)
- [Quick start](#quick-start)
- [Capturing variables](#capturing-variables)
@@ -25,11 +26,21 @@ https://user-images.githubusercontent.com/10199417/126792509-c11feb11-a609-4fab-
- [Shader metaprogramming](#shader-metaprogramming)
- [Inspecting shaders](#inspecting-shaders)
- [DirectX interop](#directx-interop)
- [Precompiled shaders](#precompiled-shaders)
- [Requirements](#requirements)
- [F# support](#f-support)
- [Sponsors](#sponsors)
- [Special thanks](#special-thanks)
# Available packages
| Name | Description | Latest version |
| ------ | ------ | ------ |
| **ComputeSharp** | The core library, with compiled shaders support | [![NuGet](https://img.shields.io/nuget/vpre/ComputeSharp.svg)](https://www.nuget.org/packages/ComputeSharp/) |
| **ComputeSharp.Dynamic** | An extension for **ComputeSharp**, enabling dynamic shader compilation at runtime and shader metaprogramming | [![NuGet](https://img.shields.io/nuget/vpre/ComputeSharp.Dynamic.svg)](https://www.nuget.org/packages/ComputeSharp.Dynamic/) |
| **ComputeSharp.Uwp** | A UWP library (targeting .NET Standard 2.0) with controls to render DX12 shaders powered by **ComputeSharp** | [![NuGet](https://img.shields.io/nuget/vpre/ComputeSharp.Uwp.svg)](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** | [![NuGet](https://img.shields.io/nuget/vpre/ComputeSharp.WinUI.svg)](https://www.nuget.org/packages/ComputeSharp.WinUI/) |
# Installing from NuGet
To install **ComputeSharp**, run the following command in the **Package Manager Console**
@@ -38,6 +49,8 @@ To install **ComputeSharp**, run the following command in the **Package Manager
Install-Package ComputeSharp
```
Alternatively, use the NuGet package manager wizard in Visual Studio or your IDE of choice.
More details available [here](https://www.nuget.org/packages/ComputeSharp/).
# Quick start
@@ -85,6 +98,8 @@ GraphicsDevice.Default.For(buffer.Length, new MultiplyByTwo(buffer));
buffer.CopyTo(array);
```
> **NOTE:** all these samples assume that **ComputeSharp.Dynamic** is also installed. For info on how to only use precompiled shaders with the base **ComputeSharp** package, see the [precompiled shaders](#precompiled-shaders) paragraph.
## Capturing variables
Shaders can store either GPU resources or custom values in their fields, so that they can be accessed when running on the GPU as well. This can be useful to pass some extra parameters to a shader (eg. some factor to multiply values by), that don't belong to a GPU buffer of their own. The captured variables need to be of a supported scalar or vector type so that they can be correctly used by the GPU shader in HLSL. Here is a list of the variable types currently supported:
@@ -336,6 +351,27 @@ InteropServices.GetID3D12Resource(buffer, __uuidof<ID3D12Resource>(), (void**)d3
The `InteropServices` class is also used by the swap chain sample to access the underlying COM objects and use them the rendered frames in a Win32 window. The full source code is available [here](https://github.com/Sergio0694/ComputeSharp/blob/main/samples/ComputeSharp.SwapChain/Backend/SwapChainApplication%7BT%7D.cs), and it provides reference implementation of how these APIs can be used to interop with other DirectX objects.
## Precompiled shaders
When only using the main **ComputeSharp** project, dynamic shader compilation is not available. This makes the library have a much smaller impact on binary size, as it will not bundle the native DirectX compiler dependencies (which add about 20MB per CPU architecture). Additionally, precompiling shaders makes the code less error prone and the startup time much faster. In order to precompile a shader, it must not have dynamic features (ie. it cannot capture delegates, see the [shader metaprogramming](#shader-metaprogramming) paragraph) and it must be annotated with the `[EmbeddedBytecode]` attribute:
```csharp
[AutoConstructor]
[EmbeddedBytecode(8, 8, 1)]
public readonly partial struct MultiplyByTwo : IPixelShader<float4>
{
public float4 Execute()
{
float2 uv = ThreadIds.Normalized.XY;
float3 col = 0.5f + 0.5f * Hlsl.Cos(new float3(uv, uv.X) + new float3(0, 2, 4));
return new(col, 1f);
}
}
```
The values in the `[EmbeddedBytecode]` attribute map to the [`[numthreads]` HLSL attribute](https://docs.microsoft.com/windows/win32/direct3dhlsl/sm5-attributes-numthreads) for the shader entry point. Make sure to use the same values when dispatching the shader at runtime (either using the `GraphicsDevice.For` overload with explicit parameters for the tread numbers, or by relying on `GraphicsDevice.ForEach` to always use `(8, 8, 1)` for thread numbers, as it will be dispatching shaders on a 2D texture).
# Requirements
Building and running **ComputeSharp** from the .NET solution filter has the following prerequisites:
@@ -380,11 +416,11 @@ For a complete example, check out the F# sample [here](https://github.com/Sergio
Huge thanks to these sponsors for directly supporting my work on **ComputeSharp**, it means a lot! 🙌
<a href="https://github.com/sebastienros"><img src="https://avatars.githubusercontent.com/u/1165805" height="auto" width="60" style="border-radius:50%"></a>
<a href="https://github.com/ptasev"><img src="https://avatars.githubusercontent.com/u/23424044" height="auto" width="60" style="border-radius:50%"></a>
<a href="https://github.com/dgellow"><img src="https://avatars.githubusercontent.com/u/2451004" height="auto" width="60" style="border-radius:50%"></a>
<a href="https://github.com/Gavin-Williams"><img src="https://avatars.githubusercontent.com/u/4374176" height="auto" width="60" style="border-radius:50%"></a>
<a href="https://github.com/hawkerm"><img src="https://avatars.githubusercontent.com/u/8959496" height="auto" width="60" style="border-radius:50%"></a>
<a href="https://github.com/ptasev"><img src="https://avatars.githubusercontent.com/u/23424044" height="auto" width="60" style="border-radius:50%"></a>
<a href="https://github.com/xoofx"><img src="https://avatars.githubusercontent.com/u/715038" height="auto" width="60" style="border-radius:50%"></a>
<a href="https://github.com/hawkerm"><img src="https://avatars.githubusercontent.com/u/8959496" height="auto" width="60" style="border-radius:50%"></a>
# Special thanks
+1
ファイルの表示
@@ -24,6 +24,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
+1
ファイルの表示
@@ -16,6 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
@@ -6,6 +6,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
+1
ファイルの表示
@@ -16,6 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
+1
ファイルの表示
@@ -8,6 +8,7 @@
<ItemGroup>
<PackageReference Include="ComputeSharp" Version="2.0.0" />
<PackageReference Include="ComputeSharp.Dynamic" Version="2.0.0" />
</ItemGroup>
<Import Project="..\ComputeSharp.Sample.Shared\ComputeSharp.Sample.Shared.projitems" Label="Shared" />
+2 -1
ファイルの表示
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="ComputeSharp-Local" value="..\..\src\ComputeSharp.Package\bin\Release" />
<add key="ComputeSharp" value="..\..\src\ComputeSharp.Package\bin\Release" />
<add key="ComputeSharp-Dynamic" value="..\..\src\ComputeSharp.Dynamic.Package\bin\Release" />
</packageSources>
</configuration>
+1
ファイルの表示
@@ -8,6 +8,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
+3
ファイルの表示
@@ -7,6 +7,9 @@
/// <para>License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct ColorfulInfinity : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -6,6 +6,9 @@
/// <para>Created by Shane.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct ContouredLayers : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -6,6 +6,9 @@
/// <para>Created by Shane.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct ExtrudedTruchetPattern : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -7,6 +7,9 @@
/// <para>License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct FourColorGradient : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -7,6 +7,9 @@
/// <para>License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct FractalTiling : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -5,6 +5,9 @@
/// Ported from <see href="https://www.shadertoy.com/new"/>.
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct HelloWorld : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -6,6 +6,9 @@
/// <para>Created by Syntopia.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct MengerJourney : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -6,6 +6,9 @@
/// <para>Created by whisky_shusuky.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct Octagrams : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -7,6 +7,9 @@
/// <para>License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct ProteanClouds : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -7,6 +7,9 @@
/// <para>Created by Shane.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct PyramidPattern : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -6,6 +6,9 @@
/// <para>Created by Shane.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct TriangleGridContouring : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -6,6 +6,9 @@
/// <para>Created by Shane.</para>
/// </summary>
[AutoConstructor]
#if SAMPLE_APP
[EmbeddedBytecode(8, 8, 1)]
#endif
internal readonly partial struct TwoTiledTruchet : IPixelShader<float4>
{
/// <summary>
+3
ファイルの表示
@@ -112,6 +112,9 @@
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);SAMPLE_APP</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
+1
ファイルの表示
@@ -10,6 +10,7 @@
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
<DefineConstants>$(DefineConstants);SAMPLE_APP</DefineConstants>
</PropertyGroup>
<ItemGroup>
+1
ファイルの表示
@@ -8,6 +8,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
+21
ファイルの表示
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.Build.NoTargets/2.0.1" DefaultTargets="Pack">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PackageId>ComputeSharp.Dynamic</PackageId>
<Title>ComputeSharp.Dynamic</Title>
<Description>An extension library for ComputeSharp to enable dynamic compilation of shaders at runtime</Description>
</PropertyGroup>
<ItemGroup>
<Content Include="..\ComputeSharp.Package\icon.png" PackFolder="\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
</ItemGroup>
</Project>
差分なしでファイル名を変更。
+80
ファイルの表示
@@ -0,0 +1,80 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<OutputPath>bin\Release</OutputPath>
<DocumentationFile>ComputeSharp.Dynamic.xml</DocumentationFile>
<Platforms>AnyCPU;x64;ARM64</Platforms>
</PropertyGroup>
<!-- Referece to the main non-dynamic library-->
<ItemGroup>
<ProjectReference Include="..\ComputeSharp\ComputeSharp.csproj" />
</ItemGroup>
<!-- Shared project with .NET Standard 2.0 polyfills for Dxc -->
<Import Condition="'$(TargetFramework)' == 'netstandard2.0'"
Project="..\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems"
Label="Shared" />
<Choose>
<!-- When building locally for x64/ARM64 (using the project through a project reference),
just copy the right native libraries to the output directory, with no subfolders. -->
<When Condition="'$(Platform)' == 'x64'">
<ItemGroup>
<None Include="Libraries\x64\dxcompiler.dll"
Link="dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
<None Include="Libraries\x64\dxil.dll"
Link="dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</When>
<When Condition="'$(Platform)' == 'ARM64'">
<ItemGroup>
<None Include="Libraries\arm64\dxcompiler.dll"
Link="dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
<None Include="Libraries\arm64\dxil.dll"
Link="dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</When>
<!-- When no RID is specified, it means the NuGet package is being packed. In this
case, copy all native libraries to the right runtimes/<RID>/native directory,
which will automatically be used by NuGet to deploy the right libs to consumers.
Still keep the link target to get the libraries to be copied to the output, which
allows them to be found even when running the library locally in Any CPU. This will
make life easier for developers using a project reference with an incorrect configuration,
while still not causing any change in the final NuGet package (Link isn't looked up there). -->
<Otherwise>
<ItemGroup>
<None Include="Libraries\x64\dxcompiler.dll"
Link="runtimes\win-x64\native\dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-x64\native" />
<None Include="Libraries\x64\dxil.dll"
Link="runtimes\win-x64\native\dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-x64\native" />
<None Include="Libraries\arm64\dxcompiler.dll"
Link="runtimes\win-arm64\native\dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-arm64\native" />
<None Include="Libraries\arm64\dxil.dll"
Link="runtimes\win-arm64\native\dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-arm64\native" />
</ItemGroup>
</Otherwise>
</Choose>
</Project>
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
+5
ファイルの表示
@@ -0,0 +1,5 @@
using System.Runtime.CompilerServices;
[module: SkipLocalsInit]
[assembly: InternalsVisibleTo("ComputeSharp.Tests.Internals")]
差分なしでファイル名を変更。
@@ -1,17 +1,11 @@
using System;
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using System.Runtime.CompilerServices;
#endif
using ComputeSharp.__Internals;
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using ComputeSharp.Core.Extensions;
using ComputeSharp.Shaders.Translation;
#else
using Microsoft.Toolkit.Diagnostics;
#endif
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#if !NET6_0_OR_GREATER
using DirectX = TerraFX.Interop.DirectX.DirectX2;
#endif
#pragma warning disable CS0618
@@ -110,14 +104,9 @@ public static class ReflectionServices
private static unsafe void GetNonGenericShaderInfo<T>(in T shader, out ShaderInfo shaderInfo)
where T : struct, IShader
{
#if DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
ThrowHelper.ThrowNotSupportedException("Runtime shader compilation is not supported by the current configuration.");
shaderInfo = default;
#else
Unsafe.AsRef(in shader).BuildHlslString(out ArrayPoolStringBuilder shaderSource, 1, 1, 1);
using ComPtr<IDxcBlob> dxcBlobBytecode = ShaderCompiler.Instance.CompileShader(shaderSource.WrittenSpan);
using ComPtr<IDxcBlob> dxcBlobBytecode = Shaders.Translation.ShaderCompiler.Instance.CompileShader(shaderSource.WrittenSpan);
shaderSource.Dispose();
@@ -169,6 +158,5 @@ public static class ReflectionServices
Unsafe.AsRef(shaderInfo.MovInstructionCount) = d3D12ShaderReflection.Get()->GetMovInstructionCount();
Unsafe.AsRef(shaderInfo.InterfaceSlotCount) = d3D12ShaderReflection.Get()->GetNumInterfaceSlots();
Unsafe.AsRef(shaderInfo.RequiresDoublePrecisionSupport) = (d3D12ShaderReflection.Get()->GetRequiresFlags() & (D3D.D3D_SHADER_REQUIRES_DOUBLES | D3D.D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS)) != 0;
#endif
}
}
差分なしでファイル名を変更。
@@ -1,4 +1,4 @@
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT && NET6_0_OR_GREATER
#if NET6_0_OR_GREATER
using System;
using System.IO;
@@ -1,12 +1,13 @@
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using System;
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using ComputeSharp.Core.Extensions;
using ComputeSharp.Exceptions;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#if !NET6_0_OR_GREATER
using DirectX = TerraFX.Interop.DirectX.DirectX2;
#endif
namespace ComputeSharp.Shaders.Translation;
@@ -155,5 +156,3 @@ internal sealed unsafe partial class ShaderCompiler
throw new HlslCompilationException(message);
}
}
#endif
+38
ファイルの表示
@@ -0,0 +1,38 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
namespace ComputeSharp.__Internals;
/// <summary>
/// A <see langword="class"/> that uses the DXC APIs to compile compute shaders.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This type is not intended to be used directly by user code")]
public static class ShaderCompiler
{
/// <summary>
/// Compiles a new HLSL shader from the input source code.
/// </summary>
/// <typeparam name="TLoadeer">The type of bytecode loader being used.</typeparam>
/// <typeparam name="T">The type of shader being dispatched.</typeparam>
/// <param name="loader">The <typeparamref name="TLoadeer"/> instance to use to load the bytecode.</param>
/// <param name="threadsX">The number of threads in each thread group for the X axis.</param>
/// <param name="threadsY">The number of threads in each thread group for the Y axis.</param>
/// <param name="threadsZ">The number of threads in each thread group for the Z axis.</param>
/// <param name="shader">The input <typeparamref name="T"/> instance representing the compute shader to run.</param>
public static unsafe void LoadDynamicBytecode<TLoadeer, T>(ref TLoadeer loader, int threadsX, int threadsY, int threadsZ, in T shader)
where TLoadeer : struct, IBytecodeLoader
where T : struct, IShader
{
Unsafe.AsRef(in shader).BuildHlslString(out ArrayPoolStringBuilder builder, threadsX, threadsY, threadsZ);
using ComPtr<IDxcBlob> dxcBlobBytecode = Shaders.Translation.ShaderCompiler.Instance.CompileShader(builder.WrittenSpan);
builder.Dispose();
loader.LoadDynamicBytecode((IntPtr)dxcBlobBytecode.Get());
}
}
+1
ファイルの表示
@@ -53,3 +53,4 @@ CMPS0043 | ComputeSharp.IComputeShader | Error | IShaderGenerator, [Documentatio
CMPS0044 | ComputeSharp.IComputeShader | Error | IShaderGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPS0045 | ComputeSharp.IComputeShader | Error | IShaderGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPS0046 | ComputeSharp.IComputeShader | Error | IShaderGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
CMPS0047 | ComputeSharp.IComputeShader | Error | IShaderGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp)
+10 -9
ファイルの表示
@@ -18,8 +18,8 @@
<Compile Include="..\ComputeSharp\Core\Attributes\AutoConstructorAttribute.cs" Link="ComputeSharp\Core\Attributes\AutoConstructorAttribute.cs" />
<Compile Include="..\ComputeSharp\Core\Attributes\EmbeddedBytecodeAttribute.cs" Link="ComputeSharp\Core\Attributes\EmbeddedBytecodeAttribute.cs" />
<Compile Include="..\ComputeSharp\Core\Attributes\GroupSharedAttribute.cs" Link="ComputeSharp\Core\Attributes\GroupSharedAttribute.cs" />
<Compile Include="..\ComputeSharp\Core\Attributes\ShaderMethodAttribute.cs" Link="ComputeSharp\Core\Attributes\ShaderMethodAttribute.cs" />
<Compile Include="..\ComputeSharp\Core\Attributes\__Internals\ShaderMethodSourceAttribute.cs" Link="ComputeSharp\Core\Attributes\__Internals\ShaderMethodSourceAttribute.cs" />
<Compile Include="..\ComputeSharp.Dynamic\Attributes\ShaderMethodAttribute.cs" Link="ComputeSharp\Core\Attributes\ShaderMethodAttribute.cs" />
<Compile Include="..\ComputeSharp.Dynamic\Attributes\__Internals\ShaderMethodSourceAttribute.cs" Link="ComputeSharp\Core\Attributes\__Internals\ShaderMethodSourceAttribute.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\DispatchSize.cs" Link="ComputeSharp\Core\Dispatch\DispatchSize.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\GridIds.cs" Link="ComputeSharp\Core\Dispatch\GridIds.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\GroupIds.cs" Link="ComputeSharp\Core\Dispatch\GroupIds.cs" />
@@ -72,9 +72,9 @@
<Compile Include="..\ComputeSharp\Core\Primitives\UInt\UIntMxN.g.cs" Link="ComputeSharp\Core\Primitives\UInt\UIntMxN.g.cs" />
<Compile Include="..\ComputeSharp\Core\Primitives\MatrixIndex.cs" Link="ComputeSharp\Core\Primitives\MatrixIndex.cs" />
<Compile Include="..\ComputeSharp\Graphics\Extensions\Interop\ComPtrExtensions.cs" Link="ComputeSharp\Graphics\Extensions\Interop\ComPtrExtensions.cs" />
<Compile Include="..\ComputeSharp\Shaders\Exceptions\HlslCompilationException.cs" Link="ComputeSharp\Shaders\Exceptions\HlslCompilationException.cs" />
<Compile Include="..\ComputeSharp\Shaders\Translation\ShaderCompiler.cs" Link="ComputeSharp\Shaders\Translation\ShaderCompiler.cs" />
<Compile Include="..\ComputeSharp\Shaders\Translation\__Internals\ArrayPoolStringBuilder.cs" Link="ComputeSharp\Shaders\Translation\__Internals\ArrayPoolStringBuilder.cs" />
<Compile Include="..\ComputeSharp.Dynamic\Shaders\Exceptions\HlslCompilationException.cs" Link="ComputeSharp\Shaders\Exceptions\HlslCompilationException.cs" />
<Compile Include="..\ComputeSharp.Dynamic\Shaders\Translation\ShaderCompiler.cs" Link="ComputeSharp\Shaders\Translation\ShaderCompiler.cs" />
<Compile Include="..\ComputeSharp\Shaders\Dispatching\__Internals\ArrayPoolStringBuilder.cs" Link="ComputeSharp\Shaders\Dispatching\__Internals\ArrayPoolStringBuilder.cs" />
</ItemGroup>
<ItemGroup>
@@ -93,10 +93,10 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\ComputeSharp\Libraries\x64\dxcompiler.dll" Link="ComputeSharp\Libraries\x64\dxcompiler.dll" />
<EmbeddedResource Include="..\ComputeSharp\Libraries\x64\dxil.dll" Link="ComputeSharp\Libraries\x64\dxil.dll" />
<EmbeddedResource Include="..\ComputeSharp\Libraries\arm64\dxcompiler.dll" Link="ComputeSharp\Libraries\arm64\dxcompiler.dll" />
<EmbeddedResource Include="..\ComputeSharp\Libraries\arm64\dxil.dll" Link="ComputeSharp\Libraries\arm64\dxil.dll" />
<EmbeddedResource Include="..\ComputeSharp.Dynamic\Libraries\x64\dxcompiler.dll" Link="ComputeSharp\Libraries\x64\dxcompiler.dll" />
<EmbeddedResource Include="..\ComputeSharp.Dynamic\Libraries\x64\dxil.dll" Link="ComputeSharp\Libraries\x64\dxil.dll" />
<EmbeddedResource Include="..\ComputeSharp.Dynamic\Libraries\arm64\dxcompiler.dll" Link="ComputeSharp\Libraries\arm64\dxcompiler.dll" />
<EmbeddedResource Include="..\ComputeSharp.Dynamic\Libraries\arm64\dxil.dll" Link="ComputeSharp\Libraries\arm64\dxil.dll" />
</ItemGroup>
<!-- Shared project with .NET Standard 2.0 polyfills -->
@@ -104,5 +104,6 @@
<!-- Shared project with TerraFX.Interop.Windows fork -->
<Import Project="..\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems" Label="Shared" />
<Import Project="..\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems" Label="Shared" />
</Project>
+22 -6
ファイルの表示
@@ -576,7 +576,7 @@ internal static class DiagnosticDescriptors
public static readonly DiagnosticDescriptor MultipleShaderTypesImplemented = new(
id: "CMPS0042",
title: "Multiple shader implementations for type declaration",
messageFormat: $"The shader of type {{0}} cannot implement more than one shader interface",
messageFormat: "The shader of type {0} cannot implement more than one shader interface",
category: typeof(IShaderGenerator).FullName,
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
@@ -592,7 +592,7 @@ internal static class DiagnosticDescriptors
public static readonly DiagnosticDescriptor EmbeddedBytecodeWithDynamicShader = new(
id: "CMPS0043",
title: "Embedded bytecode for dynamic shader",
messageFormat: $"The shader of type {{0}} cannot be precompiled, as it is dynamic (it captures delegate fields)",
messageFormat: "The shader of type {0} cannot be precompiled, as it is dynamic (it captures delegate fields)",
category: typeof(IShaderGenerator).FullName,
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
@@ -608,7 +608,7 @@ internal static class DiagnosticDescriptors
public static readonly DiagnosticDescriptor InvalidEmbeddedBytecodeThreadIds = new(
id: "CMPS0044",
title: "Invalid thread ids for shader with embedded bytecode",
messageFormat: $"The shader of type {{0}} is annotated with invalid thread ids values ({{1}}, {{2}}, {{3}})",
messageFormat: "The shader of type {0} is annotated with invalid thread ids values ({1}, {2}, {3})",
category: typeof(IShaderGenerator).FullName,
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
@@ -618,13 +618,13 @@ internal static class DiagnosticDescriptors
/// <summary>
/// Gets a <see cref="DiagnosticDescriptor"/> for an embedded bytecode shader failed due to a Win32 exception.
/// <para>
/// Format: <c>"The shader of type {{0}} failed to compile due to a Win32 exception (HRESULT: {1:X8}, Message: "{2}")"</c>.
/// Format: <c>"The shader of type {0} failed to compile due to a Win32 exception (HRESULT: {1:X8}, Message: "{2}")"</c>.
/// </para>
/// </summary>
public static readonly DiagnosticDescriptor EmbeddedBytecodeFailedWithWin32Exception = new(
id: "CMPS0045",
title: "Embedded bytecode compilation failed due to Win32 exception",
messageFormat: $"The shader of type {{0}} failed to compile due to a Win32 exception (HRESULT: {{1:X8}}, Message: \"{{2}}\")",
messageFormat: "The shader of type {0} failed to compile due to a Win32 exception (HRESULT: {1:X8}, Message: \"{2}\")",
category: typeof(IShaderGenerator).FullName,
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
@@ -640,10 +640,26 @@ internal static class DiagnosticDescriptors
public static readonly DiagnosticDescriptor EmbeddedBytecodeFailedWithHlslCompilationException = new(
id: "CMPS0046",
title: "Embedded bytecode compilation failed due to an HLSL compiler error",
messageFormat: $"The shader of type {{0}} failed to compile due to an HLSL compiler error (Message: \"{{1}}\")",
messageFormat: "The shader of type {0} failed to compile due to an HLSL compiler error (Message: \"{1}\")",
category: typeof(IShaderGenerator).FullName,
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "The embedded bytecode for a shader failed to be compiled due to an HLSL compiler error.",
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
/// <summary>
/// Gets a <see cref="DiagnosticDescriptor"/> for a shader without the embedded bytecode attribute, when dynamic shaders are not supported.
/// <para>
/// Format: <c>"The shader of type {0} needs to be annotated as having embedded bytecode (using the [EmbeddedBytecode] attribute), as dynamic shader compilation is not supported"</c>.
/// </para>
/// </summary>
public static readonly DiagnosticDescriptor MissingEmbeddedBytecodeAttributeWhenDynamicShaderCompilationIsNotSupported = new(
id: "CMPS0047",
title: "Embedded bytecode compilation failed due to an HLSL compiler error",
messageFormat: "The shader of type {0} needs to be annotated as having embedded bytecode (using the [EmbeddedBytecode] attribute), as dynamic shader compilation is not supported",
category: typeof(IShaderGenerator).FullName,
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "When dynamic shader compilation is not supported (ie. when ComputeSharp.Dynamic is not referenced), all shaders need to be annotated as having embedded bytecode (using the [EmbeddedBytecode] attribute).",
helpLinkUri: "https://github.com/Sergio0694/ComputeSharp");
}
+31 -3
ファイルの表示
@@ -21,14 +21,18 @@ public sealed partial class IShaderGenerator
/// Creates a <see cref="MethodDeclarationSyntax"/> instance for the <c>BuildHlslString</c> method.
/// </summary>
/// <param name="hlslSourceInfo">The input <see cref="HlslShaderSourceInfo"/> instance to use.</param>
/// <param name="supportsDynamicShaders">Indicates whether or not dynamic shaders are supported.</param>
/// <returns>The resulting <see cref="MethodDeclarationSyntax"/> instance for the <c>BuildHlslString</c> method.</returns>
public static MethodDeclarationSyntax GetSyntax(HlslShaderSourceInfo hlslSourceInfo)
public static MethodDeclarationSyntax GetSyntax(HlslShaderSourceInfo hlslSourceInfo, bool supportsDynamicShaders)
{
ImmutableArray<StatementSyntax> bodyStatements = GenerateRenderMethodBody(hlslSourceInfo);
// Generate the necessary body statements depending on whether dynamic shaders are supported
ImmutableArray<StatementSyntax> bodyStatements = supportsDynamicShaders
? GenerateRenderMethodBody(hlslSourceInfo)
: GenerateEmptyMethodBody();
// This code produces a method declaration as follows:
//
// readonly void global::ComputeSharp.__Internals.IShader.BuildHlslString(ref global::ComputeSharp.__Internals.ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ)
// readonly void global::ComputeSharp.__Internals.IShader.BuildHlslString(out global::ComputeSharp.__Internals.ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ)
// {
// <BODY>
// }
@@ -46,6 +50,30 @@ public sealed partial class IShaderGenerator
.WithBody(Block(bodyStatements));
}
/// <summary>
/// Produces the series of statements for the empty fallback method.
/// </summary>
/// <returns>A series of statements for when dynamic shaders are not supported.</returns>
private static ImmutableArray<StatementSyntax> GenerateEmptyMethodBody()
{
// builder = global::ComputeSharp.__Internals.ArrayPoolStringBuilder.Create(0);
return
ImmutableArray.Create<StatementSyntax>(
ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
IdentifierName("builder"),
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("global::ComputeSharp.__Internals.ArrayPoolStringBuilder"),
IdentifierName("Create")))
.AddArgumentListArguments(
Argument(LiteralExpression(
SyntaxKind.NumericLiteralExpression,
Literal(0)))))));
}
/// <summary>
/// Produces the series of statements to build the current HLSL source.
/// </summary>
+7 -5
ファイルの表示
@@ -19,9 +19,10 @@ public sealed partial class IShaderGenerator
/// <summary>
/// Creates a <see cref="MethodDeclarationSyntax"/> instance for the <c>GetDispatchId</c> method.
/// </summary>
///<param name="delegateFieldNames">The names of all <see cref="System.Delegate"/> instance fields within the current shader type.</param>
/// <param name="delegateFieldNames">The names of all <see cref="System.Delegate"/> instance fields within the current shader type.</param>\
/// <param name="supportsDynamicShaders">Indicates whether or not dynamic shaders are supported.</param>
/// <returns>The resulting <see cref="MethodDeclarationSyntax"/> instance for the <c>GetDispatchId</c> method.</returns>
public static MethodDeclarationSyntax GetSyntax(ImmutableArray<string> delegateFieldNames)
public static MethodDeclarationSyntax GetSyntax(ImmutableArray<string> delegateFieldNames, bool supportsDynamicShaders)
{
// This code produces a method declaration as follows:
//
@@ -35,18 +36,19 @@ public sealed partial class IShaderGenerator
Identifier("GetDispatchId"))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.__Internals.{nameof(IShader)}")))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.WithBody(GetShaderHashCodeBody(delegateFieldNames));
.WithBody(GetShaderHashCodeBody(delegateFieldNames, supportsDynamicShaders));
}
/// <summary>
/// Gets a <see cref="BlockSyntax"/> instance with the logic to compute the hashcode of a given shader type.
/// </summary>
/// <param name="delegateFieldNames">The names of all <see cref="System.Delegate"/> instance fields within the current shader type.</param>
/// <param name="supportsDynamicShaders">Indicates whether or not dynamic shaders are supported.</param>
/// <returns>The <see cref="BlockSyntax"/> instance to hash the input shader.</returns>
[Pure]
private static BlockSyntax GetShaderHashCodeBody(ImmutableArray<string> delegateFieldNames)
private static BlockSyntax GetShaderHashCodeBody(ImmutableArray<string> delegateFieldNames, bool supportsDynamicShaders)
{
if (delegateFieldNames.Length == 0)
if (delegateFieldNames.Length == 0 || !supportsDynamicShaders)
{
// return 0;
return
@@ -15,17 +15,18 @@ namespace ComputeSharp.SourceGenerators;
public sealed partial class IShaderGenerator
{
/// <inheritdoc/>
private static partial class TryGetBytecode
private static partial class LoadBytecode
{
/// <summary>
/// Creates a <see cref="MethodDeclarationSyntax"/> instance for the <c>TryGetBytecode</c> method.
/// </summary>
/// <param name="bytecodeInfo">The input <see cref="EmbeddedBytecodeInfo"/> instance.</param>
/// <param name="supportsDynamicShaders">Indicates whether or not dynamic shaders are supported.</param>
/// <param name="fixup">An opaque <see cref="Func{TResult}"/> instance to transform the final tree into text.</param>
/// <returns>The resulting <see cref="MethodDeclarationSyntax"/> instance for the <c>BuildHlslString</c> method.</returns>
public static MethodDeclarationSyntax GetSyntax(EmbeddedBytecodeInfo bytecodeInfo, out Func<SyntaxNode, string> fixup)
public static MethodDeclarationSyntax GetSyntax(EmbeddedBytecodeInfo bytecodeInfo, bool supportsDynamicShaders, out Func<SyntaxNode, string> fixup)
{
BlockSyntax block = GetShaderBytecodeBody(bytecodeInfo, out string? bytecodeLiterals);
BlockSyntax block = GetShaderBytecodeBody(bytecodeInfo, supportsDynamicShaders, out string? bytecodeLiterals);
if (bytecodeLiterals is not null)
{
@@ -38,21 +39,24 @@ public sealed partial class IShaderGenerator
// This code produces a method declaration as follows:
//
// readonly int global::ComputeSharp.__Internals.IShader.TryGetBytecode(int threadsX, int threadsY, int threadsZ, out ReadOnlySpan<byte> bytecode)
// readonly void global::ComputeSharp.__Internals.IShader.LoadBytecode<TLoader>(ref TLoader loader, int threadsX, int threadsY, int threadsZ)
// {
// <BODY>
// }
return
MethodDeclaration(
PredefinedType(Token(SyntaxKind.BoolKeyword)),
Identifier("TryGetBytecode"))
PredefinedType(Token(SyntaxKind.VoidKeyword)),
Identifier("LoadBytecode"))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.__Internals.{nameof(IShader)}")))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.AddTypeParameterListParameters(TypeParameter(Identifier("TLoader")))
.AddParameterListParameters(
Parameter(Identifier("loader"))
.AddModifiers(Token(SyntaxKind.RefKeyword))
.WithType(IdentifierName("TLoader")),
Parameter(Identifier("threadsX")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
Parameter(Identifier("threadsY")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
Parameter(Identifier("threadsZ")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
Parameter(Identifier("bytecode")).AddModifiers(Token(SyntaxKind.OutKeyword)).WithType(IdentifierName("global::System.ReadOnlySpan<byte>")))
Parameter(Identifier("threadsZ")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))))
.WithBody(block);
}
@@ -60,88 +64,147 @@ public sealed partial class IShaderGenerator
/// Gets a <see cref="BlockSyntax"/> instance with the logic to try to get a compiled shader bytecode.
/// </summary>
/// <param name="bytecodeInfo">The input <see cref="EmbeddedBytecodeInfo"/> instance.</param>
/// <param name="supportsDynamicShaders">Indicates whether or not dynamic shaders are supported.</param>
/// <param name="bytecodeLiterals">The resulting bytecode literals to insert into the final source code.</param>
/// <returns>The <see cref="BlockSyntax"/> instance trying to retrieve the precompiled shader.</returns>
[Pure]
private static unsafe BlockSyntax GetShaderBytecodeBody(EmbeddedBytecodeInfo bytecodeInfo, out string? bytecodeLiterals)
private static unsafe BlockSyntax GetShaderBytecodeBody(EmbeddedBytecodeInfo bytecodeInfo, bool supportsDynamicShaders, out string? bytecodeLiterals)
{
if (bytecodeInfo.Bytecode.IsEmpty)
{
bytecodeLiterals = null;
// This code produces a method declaration as follows:
//
// bytecode = default;
//
// return false;
return
Block(
ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
IdentifierName("bytecode"),
LiteralExpression(SyntaxKind.DefaultLiteralExpression, Token(SyntaxKind.DefaultKeyword)))),
ReturnStatement(
LiteralExpression(
SyntaxKind.FalseLiteralExpression)));
if (supportsDynamicShaders)
{
// Return the dynamic compilation path
return Block(GetDynamicCompilationStatement());
}
else
{
// Faulting path
return Block(GetDynamicCompilationFaultingBlock());
}
}
bytecodeLiterals = BuildShaderBytecodeExpressionString(bytecodeInfo.Bytecode.AsSpan());
// This code produces a method declaration as follows:
// This code produces a branch as follows:
//
// if (threadsX == <X> && threadsY == <Y> && threadsZ == <Z>)
// {
// bytecode = new byte[] { __EMBEDDED_SHADER_BYTECODE };
//
// return true;
// global::System.ReadOnlySpan<byte> bytecode = new byte[] { __EMBEDDED_SHADER_BYTECODE };
// loader.LoadEmbeddedBytecode(bytecode);
// }
//
// bytecode = default;
//
// return false;
//
// Note that the __EMBEDDED_SHADER_BYTECODE identifier will be replaced after the string
// is created by the generator. This greatly speeds up the code generation, as it avoids
// having to create/parse tens of thousands of literal expression nodes for every shader.
return
Block(
IfStatement(
IfStatementSyntax embeddedBranch =
IfStatement(
BinaryExpression(
SyntaxKind.LogicalAndExpression,
BinaryExpression(
SyntaxKind.LogicalAndExpression,
BinaryExpression(
SyntaxKind.LogicalAndExpression,
BinaryExpression(
SyntaxKind.EqualsExpression,
IdentifierName("threadsX"),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(bytecodeInfo.X))),
BinaryExpression(
SyntaxKind.EqualsExpression,
IdentifierName("threadsY"),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(bytecodeInfo.Y)))),
SyntaxKind.EqualsExpression,
IdentifierName("threadsX"),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(bytecodeInfo.X))),
BinaryExpression(
SyntaxKind.EqualsExpression,
IdentifierName("threadsZ"),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(bytecodeInfo.Z)))),
Block(
ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
IdentifierName("bytecode"),
ArrayCreationExpression(
IdentifierName("threadsY"),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(bytecodeInfo.Y)))),
BinaryExpression(
SyntaxKind.EqualsExpression,
IdentifierName("threadsZ"),
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(bytecodeInfo.Z)))),
Block(
LocalDeclarationStatement(
VariableDeclaration(
GenericName(Identifier("global::System.ReadOnlySpan"))
.AddTypeArgumentListArguments(PredefinedType(Token(SyntaxKind.ByteKeyword))))
.AddVariables(
VariableDeclarator(Identifier("bytecode"))
.WithInitializer(
EqualsValueClause(
ArrayCreationExpression(
ArrayType(PredefinedType(Token(SyntaxKind.ByteKeyword)))
.AddRankSpecifiers(ArrayRankSpecifier(SingletonSeparatedList<ExpressionSyntax>(OmittedArraySizeExpression()))))
.WithInitializer(
InitializerExpression(
SyntaxKind.ArrayInitializerExpression,
SingletonSeparatedList<ExpressionSyntax>(IdentifierName("__EMBEDDED_SHADER_BYTECODE")))))),
ReturnStatement(LiteralExpression(SyntaxKind.TrueLiteralExpression)))),
ExpressionStatement(
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
IdentifierName("bytecode"),
LiteralExpression(SyntaxKind.DefaultLiteralExpression, Token(SyntaxKind.DefaultKeyword)))),
ReturnStatement(LiteralExpression(SyntaxKind.FalseLiteralExpression)));
SingletonSeparatedList<ExpressionSyntax>(IdentifierName("__EMBEDDED_SHADER_BYTECODE")))))))),
ExpressionStatement(
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("loader"),
IdentifierName("LoadEmbeddedBytecode")))
.AddArgumentListArguments(Argument(IdentifierName("bytecode"))))));
// If dynamic shaders are supported, return the combined block
if (supportsDynamicShaders)
{
return Block(embeddedBranch.WithElse(ElseClause(Block(GetDynamicCompilationStatement()))));
}
// If there is no dynamic shader support, add the faulting path after the branch
return Block(embeddedBranch.WithElse(ElseClause(Block(GetDynamicCompilationFaultingBlock()))));
}
/// <summary>
/// The cached tree of dynamic statements.
/// </summary>
private static StatementSyntax? dynamicStatement;
/// <summary>
/// Returns the <see cref="StatementSyntax"/> instance to create a new dynamic shader.
/// </summary>
/// <returns>The <see cref="StatementSyntax"/> instance to create a new dynamic shader.</returns>
private static StatementSyntax GetDynamicCompilationStatement()
{
// This code produces a method declaration as follows:
//
// ComputeSharp.__Internals.ShaderCompiler.LoadDynamicBytecode(ref loader, threadsX, threadsY, threadsZ, in this);
return dynamicStatement ??=
ExpressionStatement(
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("ComputeSharp.__Internals.ShaderCompiler"),
IdentifierName("LoadDynamicBytecode")))
.AddArgumentListArguments(
Argument(IdentifierName("loader")).WithRefOrOutKeyword(Token(SyntaxKind.RefKeyword)),
Argument(IdentifierName("threadsX")),
Argument(IdentifierName("threadsY")),
Argument(IdentifierName("threadsZ")),
Argument(ThisExpression()).WithRefOrOutKeyword(Token(SyntaxKind.InKeyword))));
}
/// <summary>
/// The cached tree of dynamic fault statement.
/// </summary>
private static ExpressionStatementSyntax? dynamicFaultStatement;
/// <summary>
/// Returns a <see cref="ExpressionStatementSyntax"/> instances to perform a faulting call to <c>LoadDynamicBytecode(IntPtr)</c>.
/// </summary>
/// <returns>A <see cref="ExpressionStatementSyntax"/> instances to perform a faulting call to <c>LoadDynamicBytecode(IntPtr)</c>.</returns>
private static ExpressionStatementSyntax GetDynamicCompilationFaultingBlock()
{
// This code produces a faulting call as follows:
//
// loader.LoadDynamicBytecode(default);
return dynamicFaultStatement ??=
ExpressionStatement(
InvocationExpression(
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("loader"),
IdentifierName("LoadDynamicBytecode")))
.AddArgumentListArguments(
Argument(LiteralExpression(
SyntaxKind.DefaultLiteralExpression,
Token(SyntaxKind.DefaultKeyword)))));
}
/// <summary>
@@ -23,35 +23,43 @@ namespace ComputeSharp.SourceGenerators;
public sealed partial class IShaderGenerator
{
/// <summary>
/// A helper with all logic to generate the <c>TryGetBytecode</c> method.
/// A helper with all logic to generate the <c>LoadBytecode</c> method.
/// </summary>
private static partial class TryGetBytecode
private static partial class LoadBytecode
{
/// <summary>
/// Gets the thread ids values for a given shader type, if available.
/// </summary>
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
/// <param name="isDynamicShader">Indicates whether or not the shader is dynamic (ie. captures delegates).</param>
/// <param name="supportsDynamicShaders">Indicates whether or not dynamic shaders are supported.</param>
/// <param name="diagnostics">The resulting diagnostics from the processing operation.</param>
/// <returns>The thread ids for the precompiled shader, if available.</returns>
public static ThreadIdsInfo GetInfo(
INamedTypeSymbol structDeclarationSymbol,
bool isDynamicShader,
bool supportsDynamicShaders,
out ImmutableArray<Diagnostic> diagnostics)
{
ImmutableArray<Diagnostic>.Builder builder = ImmutableArray.CreateBuilder<Diagnostic>();
AttributeData? attribute = structDeclarationSymbol
.GetAttributes()
.FirstOrDefault(static a => a.AttributeClass?.ToDisplayString() == typeof(EmbeddedBytecodeAttribute).FullName);
if (attribute is null)
{
diagnostics = ImmutableArray<Diagnostic>.Empty;
// Emit the diagnostics if dynamic shaders are not supported
if (!supportsDynamicShaders)
{
builder.Add(MissingEmbeddedBytecodeAttributeWhenDynamicShaderCompilationIsNotSupported, structDeclarationSymbol, structDeclarationSymbol);
}
diagnostics = builder.ToImmutable();
return new(true, 0, 0, 0);
}
ImmutableArray<Diagnostic>.Builder builder = ImmutableArray.CreateBuilder<Diagnostic>();
// Validate the thread number arguments
if (attribute.ConstructorArguments.Length != 3 ||
attribute.ConstructorArguments[0].Value is not int threadsX ||
@@ -32,7 +32,7 @@ public sealed partial class IShaderGenerator
{
// This code produces a method declaration as follows:
//
// readonly void global::ComputeSharp.__Internals.IShader.LoadDispatchData<TDataLoader>(ref TDataLoader loader, global::ComputeSharp.GraphicsDevice device, int x, int y, int z)
// readonly void global::ComputeSharp.__Internals.IShader.LoadDispatchData<TLoader>(ref TLoader loader, global::ComputeSharp.GraphicsDevice device, int x, int y, int z)
// {
// <BODY>
// }
@@ -42,11 +42,11 @@ public sealed partial class IShaderGenerator
Identifier("LoadDispatchData"))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.__Internals.{nameof(IShader)}")))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.AddTypeParameterListParameters(TypeParameter(Identifier("TDataLoader")))
.AddTypeParameterListParameters(TypeParameter(Identifier("TLoader")))
.AddParameterListParameters(
Parameter(Identifier("loader"))
.AddModifiers(Token(SyntaxKind.RefKeyword))
.WithType(IdentifierName("TDataLoader")),
.WithType(IdentifierName("TLoader")),
Parameter(Identifier("device")).WithType(IdentifierName("global::ComputeSharp.GraphicsDevice")),
Parameter(Identifier("x")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
Parameter(Identifier("y")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
@@ -25,7 +25,7 @@ public sealed partial class IShaderGenerator
{
// This code produces a method declaration as follows:
//
// readonly void global::ComputeSharp.__Internals.IShader.LoadDispatchMetadata<TMetadataLoader>(ref TMetadataLoader loader, out global::System.IntPtr result)
// readonly void global::ComputeSharp.__Internals.IShader.LoadDispatchMetadata<TLoader>(ref TLoader loader, out global::System.IntPtr result)
// {
// <BODY>
// }
@@ -35,11 +35,11 @@ public sealed partial class IShaderGenerator
Identifier("LoadDispatchMetadata"))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName($"global::ComputeSharp.__Internals.{nameof(IShader)}")))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.AddTypeParameterListParameters(TypeParameter(Identifier("TMetadataLoader")))
.AddTypeParameterListParameters(TypeParameter(Identifier("TLoader")))
.AddParameterListParameters(
Parameter(Identifier("loader"))
.AddModifiers(Token(SyntaxKind.RefKeyword))
.WithType(IdentifierName("TMetadataLoader")),
.WithType(IdentifierName("TLoader")),
Parameter(Identifier("result"))
.AddModifiers(Token(SyntaxKind.OutKeyword))
.WithType(IdentifierName($"global::System.{typeof(IntPtr).Name}")))
+34 -25
ファイルの表示
@@ -29,6 +29,12 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
compilation.Options is CSharpCompilationOptions { AllowUnsafe: true } &&
compilation.GetTypeByMetadataName("System.Runtime.CompilerServices.SkipLocalsInitAttribute") is not null);
// Check whether or not dynamic shaders are supported
IncrementalValueProvider<bool> supportsDynamicShaders =
context.CompilationProvider
.Select(static (compilation, token) => compilation.ReferencedAssemblyNames.Any(
static identity => identity.Name is "ComputeSharp.Dynamic"));
// Get all declared struct types and their type symbols
IncrementalValuesProvider<(StructDeclarationSyntax Syntax, INamedTypeSymbol Symbol)> structDeclarations =
context.SyntaxProvider
@@ -61,32 +67,33 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
.WithComparers(HierarchyInfo.Comparer.Default, DispatchIdInfo.Comparer.Default);
// Generate the GetDispatchId() methods
context.RegisterSourceOutput(hierarchyAndDispatchIdInfo, static (context, item) =>
context.RegisterSourceOutput(hierarchyAndDispatchIdInfo.Combine(supportsDynamicShaders), static (context, item) =>
{
MethodDeclarationSyntax getDispatchIdMethod = GetDispatchId.GetSyntax(item.Info.Delegates);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, getDispatchIdMethod, false);
MethodDeclarationSyntax getDispatchIdMethod = GetDispatchId.GetSyntax(item.Left.Info.Delegates, item.Right);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Left.Hierarchy, getDispatchIdMethod, false);
context.AddSource($"{item.Hierarchy.FilenameHint}.GetDispatchId", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8));
context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(GetDispatchId)}", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8));
});
// Get the dispatch data, HLSL source and embedded bytecode info. This info is computed on the
// same step as parts are shared in following sub-branches in the incremental generator pipeline.
IncrementalValuesProvider<(Result<DispatchDataInfo> Dispatch, Result<HlslShaderSourceInfo> Hlsl, Result<ThreadIdsInfo> ThreadIds)> shaderInfoWithErrors =
shaderDeclarations
.Combine(supportsDynamicShaders)
.Combine(context.CompilationProvider)
.Select(static (item, token) =>
{
// LoadDispatchData() info
ImmutableArray<FieldInfo> fieldInfos = LoadDispatchData.GetInfo(
item.Left.Symbol,
item.Left.Type,
item.Left.Left.Symbol,
item.Left.Left.Type,
out int resourceCount,
out int root32BitConstantCount,
out ImmutableArray<Diagnostic> dispatchDataDiagnostics);
DispatchDataInfo dispatchDataInfo = new(
item.Left.Hierarchy,
item.Left.Type,
item.Left.Left.Hierarchy,
item.Left.Left.Type,
fieldInfos,
resourceCount,
root32BitConstantCount);
@@ -94,14 +101,15 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
// BuildHlslString() info
HlslShaderSourceInfo hlslSourceInfo = BuildHlslString.GetInfo(
item.Right,
item.Left.Syntax,
item.Left.Symbol,
item.Left.Left.Syntax,
item.Left.Left.Symbol,
out ImmutableArray<Diagnostic> hlslSourceDiagnostics);
// TryGetBytecode() info
ThreadIdsInfo threadIds = TryGetBytecode.GetInfo(
item.Left.Symbol,
ThreadIdsInfo threadIds = LoadBytecode.GetInfo(
item.Left.Left.Symbol,
!hlslSourceInfo.Delegates.IsEmpty,
item.Left.Right,
out ImmutableArray<Diagnostic> threadIdsDiagnostics);
return (
@@ -137,22 +145,23 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
item.Left.Root32BitConstantCount);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Left.Hierarchy, loadDispatchDataMethod, item.Right);
context.AddSource($"{item.Left.Hierarchy.FilenameHint}.LoadDispatchData", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8));
});
context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(LoadDispatchData)}", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8));
});
// Get the filtered sequence to enable caching
IncrementalValuesProvider<(HierarchyInfo Hierarchy, HlslShaderSourceInfo SourceInfo)> hlslSourceInfo =
IncrementalValuesProvider<(HierarchyInfo Hierarchy, HlslShaderSourceInfo SourceInfo, bool SupportsDynamicShaders)> hlslSourceInfo =
shaderInfo
.Select(static (item, token) => (item.Dispatch.Hierarchy, item.Hlsl))
.WithComparers(HierarchyInfo.Comparer.Default, HlslShaderSourceInfo.Comparer.Default);
.Combine(supportsDynamicShaders)
.Select(static (item, token) => (item.Left.Dispatch.Hierarchy, item.Left.Hlsl, item.Right))
.WithComparers(HierarchyInfo.Comparer.Default, HlslShaderSourceInfo.Comparer.Default, EqualityComparer<bool>.Default);
// Generate the BuildHlslString() methods
context.RegisterSourceOutput(hlslSourceInfo.Combine(canUseSkipLocalsInit), static (context, item) =>
{
MethodDeclarationSyntax buildHlslStringMethod = BuildHlslString.GetSyntax(item.Left.SourceInfo);
MethodDeclarationSyntax buildHlslStringMethod = BuildHlslString.GetSyntax(item.Left.SourceInfo, item.Left.SupportsDynamicShaders);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Left.Hierarchy, buildHlslStringMethod, item.Right);
context.AddSource($"{item.Left.Hierarchy.FilenameHint}.BuildHlslString", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8));
context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(BuildHlslString)}", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8));
});
// Get the dispatch metadata info
@@ -173,7 +182,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
MethodDeclarationSyntax buildHlslStringMethod = LoadDispatchMetadata.GetSyntax(item.Left.MetadataInfo);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Left.Hierarchy, buildHlslStringMethod, item.Right);
context.AddSource($"{item.Left.Hierarchy.FilenameHint}.LoadDispatchMetadata", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8));
context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(LoadDispatchMetadata)}", SourceText.From(compilationUnit.ToFullString(), Encoding.UTF8));
});
// Transform the raw HLSL source to compile
@@ -187,7 +196,7 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
shaderBytecodeInfo
.Select(static (item, token) =>
{
ImmutableArray<byte> bytecode = TryGetBytecode.GetBytecode(item.ThreadIds, item.Hlsl, out DiagnosticInfo? diagnostic);
ImmutableArray<byte> bytecode = LoadBytecode.GetBytecode(item.ThreadIds, item.Hlsl, out DiagnosticInfo? diagnostic);
EmbeddedBytecodeInfo bytecodeInfo = new(
item.ThreadIds.X,
@@ -225,13 +234,13 @@ public sealed partial class IShaderGenerator : IIncrementalGenerator
.WithComparers(HierarchyInfo.Comparer.Default, EmbeddedBytecodeInfo.Comparer.Default);
// Generate the TryGetBytecode() methods
context.RegisterSourceOutput(embeddedBytecode, static (context, item) =>
context.RegisterSourceOutput(embeddedBytecode.Combine(supportsDynamicShaders), static (context, item) =>
{
MethodDeclarationSyntax tryGetBytecodeMethod = TryGetBytecode.GetSyntax(item.BytecodeInfo, out Func<SyntaxNode, string> fixup);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Hierarchy, tryGetBytecodeMethod, false);
MethodDeclarationSyntax tryGetBytecodeMethod = LoadBytecode.GetSyntax(item.Left.BytecodeInfo, item.Right, out Func<SyntaxNode, string> fixup);
CompilationUnitSyntax compilationUnit = GetCompilationUnitFromMethod(item.Left.Hierarchy, tryGetBytecodeMethod, false);
string text = fixup(compilationUnit);
context.AddSource($"{item.Hierarchy.FilenameHint}.TryGetBytecode", SourceText.From(text, Encoding.UTF8));
context.AddSource($"{item.Left.Hierarchy.FilenameHint}.{nameof(LoadBytecode)}", SourceText.From(text, Encoding.UTF8));
});
}
}
+8 -1
ファイルの表示
@@ -79,7 +79,14 @@ internal sealed record HierarchyInfo(string FilenameHint, string MetadataName, s
/// <inheritdoc/>
public int GetHashCode(HierarchyInfo obj)
{
return HashCode.Combine(obj.Namespace, obj.MetadataName, obj.Names, obj.Names[0]);
HashCode hashCode = default;
hashCode.Add(obj.FilenameHint);
hashCode.Add(obj.MetadataName);
hashCode.Add(obj.Namespace);
hashCode.AddRange(obj.Names);
return hashCode.ToHashCode();
}
}
}
+6 -79
ファイルの表示
@@ -3,9 +3,6 @@
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<OutputPath>bin\Release</OutputPath>
<DocumentationFile>ComputeSharp.xml</DocumentationFile>
<Description>ComputeSharp</Description>
<Platforms>AnyCPU;x64;ARM64</Platforms>
<DisableShaderCompilationSupport>false</DisableShaderCompilationSupport>
</PropertyGroup>
<ItemGroup>
@@ -24,90 +21,16 @@
</ItemGroup>
<!-- Shared project with .NET Standard 2.0 polyfills -->
<Import Condition="'$(TargetFramework)' == 'netstandard2.0'"
Project="..\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems"
Label="Shared" />
<Import Condition="'$(TargetFramework)' == 'netstandard2.0'" Project="..\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems" Label="Shared" />
<!-- Shared project with TerraFX.Interop.Windows fork -->
<Import Condition="'$(TargetFramework)' == 'netstandard2.0'"
Project="..\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems"
Label="Shared" />
<Import Condition="'$(TargetFramework)' == 'netstandard2.0'" Project="..\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems" Label="Shared" />
<!-- Ignore the warnings on the .NET Standard 2.0 profile -->
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>
<!-- Define DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT if requested -->
<PropertyGroup Condition="'$(DisableShaderCompilationSupport)' == 'true'">
<DefineConstants>$(DefineConstants);DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT</DefineConstants>
</PropertyGroup>
<Choose>
<!-- Skip bundling any native library if support is disabled -->
<When Condition="'$(DisableShaderCompilationSupport)' == 'true'"/>
<!-- When building locally for x64/ARM64 (using the project through a project reference),
just copy the right native libraries to the output directory, with no subfolders. -->
<When Condition="'$(Platform)' == 'x64'">
<ItemGroup>
<None Include="Libraries\x64\dxcompiler.dll"
Link="dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
<None Include="Libraries\x64\dxil.dll"
Link="dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</When>
<When Condition="'$(Platform)' == 'ARM64'">
<ItemGroup>
<None Include="Libraries\arm64\dxcompiler.dll"
Link="dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
<None Include="Libraries\arm64\dxil.dll"
Link="dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</When>
<!-- When no RID is specified, it means the NuGet package is being packed. In this
case, copy all native libraries to the right runtimes/<RID>/native directory,
which will automatically be used by NuGet to deploy the right libs to consumers.
Still keep the link target to get the libraries to be copied to the output, which
allows them to be found even when running the library locally in Any CPU. This will
make life easier for developers using a project reference with an incorrect configuration,
while still not causing any change in the final NuGet package (Link isn't looked up there). -->
<Otherwise>
<ItemGroup>
<None Include="Libraries\x64\dxcompiler.dll"
Link="runtimes\win-x64\native\dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-x64\native" />
<None Include="Libraries\x64\dxil.dll"
Link="runtimes\win-x64\native\dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-x64\native" />
<None Include="Libraries\arm64\dxcompiler.dll"
Link="runtimes\win-arm64\native\dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-arm64\native" />
<None Include="Libraries\arm64\dxil.dll"
Link="runtimes\win-arm64\native\dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-arm64\native" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
@@ -306,4 +229,8 @@
<LastGenOutput>UIntMxN.g.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Shaders\Dispatching\__Internals\" />
</ItemGroup>
</Project>
+26
ファイルの表示
@@ -0,0 +1,26 @@
using System;
using System.ComponentModel;
namespace ComputeSharp.__Internals;
/// <summary>
/// A base <see langword="interface"/> representing a bytecode loader for a shader being dispatched.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This interface is not intended to be used directly by user code")]
public interface IBytecodeLoader
{
/// <summary>
/// Loads a dynamic shader bytecode.
/// </summary>
/// <param name="handle">An opaque handle to the shader bytecode.</param>
/// <exception cref="InvalidOperationException">Thrown if the shader has already been initialized.</exception>
void LoadDynamicBytecode(IntPtr handle);
/// <summary>
/// Loads the embedded shader bytecode for the shader being dispatched.
/// </summary>
/// <param name="bytecode">The shader bytecode.</param>
/// <exception cref="InvalidOperationException">Thrown if the shader has already been initialized.</exception>
void LoadEmbeddedBytecode(ReadOnlySpan<byte> bytecode);
}
+13 -13
ファイルの表示
@@ -28,16 +28,16 @@ public interface IShader
/// <summary>
/// Loads the dispatch data for the shader.
/// </summary>
/// <typeparam name="TDataLoader">The type of data loader being used.</typeparam>
/// <param name="loader">The <typeparamref name="TDataLoader"/> instance to use to load the data.</param>
/// <typeparam name="TLoader">The type of data loader being used.</typeparam>
/// <param name="loader">The <typeparamref name="TLoader"/> instance to use to load the data.</param>
/// <param name="device">The device the shader is being dispatched on.</param>
/// <param name="x">The number of iterations to run on the X axis.</param>
/// <param name="y">The number of iterations to run on the Y axis.</param>
/// <param name="z">The number of iterations to run on the Z axis.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method is not intended to be called directly by user code")]
void LoadDispatchData<TDataLoader>(ref TDataLoader loader, GraphicsDevice device, int x, int y, int z)
where TDataLoader : struct, IDispatchDataLoader
void LoadDispatchData<TLoader>(ref TLoader loader, GraphicsDevice device, int x, int y, int z)
where TLoader : struct, IDispatchDataLoader
#if NET6_0_OR_GREATER
{
throw new NotImplementedException();
@@ -49,13 +49,13 @@ public interface IShader
/// <summary>
/// Loads an opaque metadata handle from the metadata of the current shader.
/// </summary>
/// <typeparam name="TMetadataLoader">The type of data loader being used.</typeparam>
/// <param name="loader">The <typeparamref name="TMetadataLoader"/> instance to use to load the data.</param>
/// <typeparam name="TLoader">The type of data loader being used.</typeparam>
/// <param name="loader">The <typeparamref name="TLoader"/> instance to use to load the data.</param>
/// <param name="result">The resulting opaque metadata handle.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method is not intended to be called directly by user code")]
void LoadDispatchMetadata<TMetadataLoader>(ref TMetadataLoader loader, out IntPtr result)
where TMetadataLoader : struct, IDispatchMetadataLoader
void LoadDispatchMetadata<TLoader>(ref TLoader loader, out IntPtr result)
where TLoader : struct, IDispatchMetadataLoader
#if NET6_0_OR_GREATER
{
throw new NotImplementedException();
@@ -83,17 +83,17 @@ public interface IShader
#endif
/// <summary>
/// Tries to retrieve the precompiled bytecode for the current shader.
/// Loads the bytecode for the current shader.
/// </summary>
/// <typeparam name="TLoader">The type of bytecode loader being used.</typeparam>
/// <param name="loader">The <typeparamref name="TLoader"/> instance to use to load the bytecode.</param>
/// <param name="threadsX">The number of threads in each thread group for the X axis.</param>
/// <param name="threadsY">The number of threads in each thread group for the Y axis.</param>
/// <param name="threadsZ">The number of threads in each thread group for the Z axis.</param>
/// <param name="bytecode">The resulting bytecode, if found.</param>
/// <returns>Whether or not a precompiled bytecode was found.</returns>
/// <remarks>The underlying buffer for <paramref name="bytecode"/>, if found, can be assumed to always be pinned.</remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method is not intended to be used directly by user code")]
bool TryGetBytecode(int threadsX, int threadsY, int threadsZ, out ReadOnlySpan<byte> bytecode)
void LoadBytecode<TLoader>(ref TLoader loader, int threadsX, int threadsY, int threadsZ)
where TLoader : struct, IBytecodeLoader
#if NET6_0_OR_GREATER
{
throw new NotImplementedException();
+3 -1
ファイルの表示
@@ -2,6 +2,8 @@
[module: SkipLocalsInit]
[assembly: InternalsVisibleTo("ComputeSharp.Tests.Internals")]
[assembly: InternalsVisibleTo("ComputeSharp.Dynamic")]
[assembly: InternalsVisibleTo("ComputeSharp.Uwp")]
[assembly: InternalsVisibleTo("ComputeSharp.WinUI")]
[assembly: InternalsVisibleTo("ComputeSharp.Tests.Internals")]
+65
ファイルの表示
@@ -0,0 +1,65 @@
using System;
using System.Runtime.CompilerServices;
using ComputeSharp.__Internals;
using Microsoft.Toolkit.Diagnostics;
using TerraFX.Interop.DirectX;
using ComputeSharp.Shaders.Translation.Models;
#pragma warning disable CS0618
namespace ComputeSharp.Shaders.Dispatching;
/// <summary>
/// A bytecode loader for compute shaders.
/// </summary>
internal struct ShaderBytecodeLoader : IBytecodeLoader
{
/// <summary>
/// The current cached shader instance.
/// </summary>
private ICachedShader? cachedShader;
/// <summary>
/// Gets the current cached shader instance.
/// </summary>
/// <returns>The current <see cref="ICachedShader"/> instance.</returns>
/// <exception cref="InvalidOperationException">Thrown if the shader has not been initialized.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ICachedShader GetCachedShader()
{
if (this.cachedShader is not ICachedShader cachedShader)
{
return ThrowHelper.ThrowInvalidOperationException<ICachedShader>("The shader has not been initialized.");
}
return cachedShader;
}
/// <inheritdoc/>
public unsafe void LoadDynamicBytecode(IntPtr handle)
{
if (this.cachedShader is not null)
{
ThrowHelper.ThrowInvalidOperationException("The shader has already been initialized.");
}
if (handle == IntPtr.Zero)
{
ThrowHelper.ThrowNotSupportedException("Runtime shader compilation is not supported by the current configuration.");
}
this.cachedShader = new ICachedShader.Dynamic((IDxcBlob*)handle);
}
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void LoadEmbeddedBytecode(ReadOnlySpan<byte> bytecode)
{
if (this.cachedShader is not null)
{
ThrowHelper.ThrowInvalidOperationException("The shader has already been initialized.");
}
this.cachedShader = new ICachedShader.Embedded(bytecode);
}
}
差分なしでファイル名を変更。
差分なしでファイル名を変更。
+3 -21
ファイルの表示
@@ -4,9 +4,6 @@ using System.Runtime.CompilerServices;
using ComputeSharp.Graphics.Commands;
using ComputeSharp.Shaders.Dispatching;
using ComputeSharp.Shaders.Extensions;
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using ComputeSharp.Shaders.Translation;
#endif
using ComputeSharp.Shaders.Translation.Models;
using ComputeSharp.__Internals;
using Microsoft.Toolkit.Diagnostics;
@@ -228,26 +225,11 @@ internal static class ShaderRunner<T>
[MethodImpl(MethodImplOptions.NoInlining)]
private static unsafe void LoadShader(int threadsX, int threadsY, int threadsZ, ref T shader, out ICachedShader shaderData)
{
if (Unsafe.NullRef<T>().TryGetBytecode(threadsX, threadsY, threadsZ, out ReadOnlySpan<byte> bytecode))
{
shaderData = new ICachedShader.Embedded(bytecode);
}
else
{
#if DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
ThrowHelper.ThrowNotSupportedException("Runtime shader compilation is not supported by the current configuration.");
ShaderBytecodeLoader bytecodeLoader = default;
shaderData = null!;
#else
shader.BuildHlslString(out ArrayPoolStringBuilder builder, threadsX, threadsY, threadsZ);
shader.LoadBytecode(ref bytecodeLoader, threadsX, threadsY, threadsZ);
using ComPtr<IDxcBlob> dxcBlobBytecode = ShaderCompiler.Instance.CompileShader(builder.WrittenSpan);
builder.Dispose();
shaderData = new ICachedShader.Dynamic(dxcBlobBytecode.Get());
#endif
}
shaderData = bytecodeLoader.GetCachedShader();
}
/// <summary>
@@ -3,19 +3,16 @@
// Ported from um/dxcapi.h in the Windows SDK for Windows 10.0.20348.0
// Original source is Copyright © Microsoft. All rights reserved. Licensed under the University of Illinois Open Source License.
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using System;
using System.Runtime.InteropServices;
using TerraFX.Interop.Windows;
namespace TerraFX.Interop.DirectX
{
internal static unsafe partial class DirectX
// This type is named DirectX2 to avoid naming conflicts in ComputeSharp.Dynamic
internal static unsafe partial class DirectX2
{
[DllImport("dxcompiler", ExactSpelling = true)]
public static extern HRESULT DxcCreateInstance([NativeTypeName("const IID &")] Guid* rclsid, [NativeTypeName("const IID &")] Guid* riid, [NativeTypeName("LPVOID *")] void** ppv);
}
}
#endif
+14
ファイルの表示
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>158f984d-cd96-4062-bd02-2268946031a0</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>TerraFX.Interop.Windows.Dynamic</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)DirectX.cs" />
</ItemGroup>
</Project>
+13
ファイルの表示
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>158f984d-cd96-4062-bd02-2268946031a0</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="TerraFX.Interop.Windows.Dynamic.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
-1
ファイルの表示
@@ -197,7 +197,6 @@
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3dcommon\D3D_TESSELLATOR_PARTITIONING.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\d3dcommon\ID3DBlob.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\dxcapi\CLSID.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\dxcapi\DirectX.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\dxcapi\DxcBuffer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\dxcapi\DxcDefine.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DirectX\um\dxcapi\IDxcBlob.cs" />
@@ -22,11 +22,6 @@
PrivateAssets="contentfiles;build" />
</ItemGroup>
<!-- Define DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT if requested -->
<PropertyGroup Condition="'$(DisableShaderCompilationSupport)' == 'true'">
<DefineConstants>$(DefineConstants);DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT</DefineConstants>
</PropertyGroup>
<!-- When the .NET Standard 2.0 version of ComputeSharp is resolved, the TerraFX APIs are internal, as they
are referenced from the shared project. The same reference is needed here to make all tests build fine. -->
<Import Condition="'$(TargetFramework)' != 'net6.0'" Project="..\..\src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems" />
-47
ファイルの表示
@@ -1,6 +1,5 @@
using System;
using System.Linq;
using ComputeSharp.Interop;
using ComputeSharp.Tests.Attributes;
using ComputeSharp.Tests.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -11,22 +10,10 @@ namespace ComputeSharp.Tests.DisableDynamicCompilation;
[TestCategory("Dispatch")]
public partial class DispatchTests
{
private static readonly bool IsDynamicCompilationDisabled =
#if DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
true;
#else
false;
#endif
[CombinatorialTestMethod]
[AllDevices]
public void ComputeShader_Test_Ok(Device device)
{
if (!IsDynamicCompilationDisabled)
{
Assert.Inconclusive();
}
float[] array = Enumerable.Range(0, 128).Select(static i => (float)i).ToArray();
using ReadWriteBuffer<float> buffer = device.Get().AllocateReadWriteBuffer(array);
@@ -48,11 +35,6 @@ public partial class DispatchTests
[ExpectedException(typeof(NotSupportedException))]
public void ComputeShader_Test_Fail(Device device)
{
if (!IsDynamicCompilationDisabled)
{
Assert.Inconclusive();
}
using ReadWriteBuffer<float> buffer = device.Get().AllocateReadWriteBuffer<float>(128);
device.Get().For(128, 1, 1, 64, 1, 1, new ComputeShader(buffer, 2.0f));
@@ -76,11 +58,6 @@ public partial class DispatchTests
[AllDevices]
public void PixelShader_Test_Ok(Device device)
{
if (!IsDynamicCompilationDisabled)
{
Assert.Inconclusive();
}
using ReadWriteTexture2D<Rgba32, float4> texture = device.Get().AllocateReadWriteTexture2D<Rgba32, float4>(128, 128);
device.Get().ForEach(texture, new PixelShader(0.3f, 0.6f));
@@ -120,28 +97,4 @@ public partial class DispatchTests
return new(ThreadIds.Normalized.X, ThreadIds.Normalized.Y, b, a);
}
}
[TestMethod]
[ExpectedException(typeof(NotSupportedException))]
public void ReflectionService_ComputeShader()
{
if (!IsDynamicCompilationDisabled)
{
Assert.Inconclusive();
}
ReflectionServices.GetShaderInfo<ComputeShader>(out _);
}
[TestMethod]
[ExpectedException(typeof(NotSupportedException))]
public void ReflectionService_PixelShader()
{
if (!IsDynamicCompilationDisabled)
{
Assert.Inconclusive();
}
ReflectionServices.GetShaderInfo<PixelShader, float4>(out _);
}
}
+1 -6
ファイルの表示
@@ -4,12 +4,6 @@
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<Platforms>AnyCPU;x64;ARM64</Platforms>
<DisableShaderCompilationSupport>false</DisableShaderCompilationSupport>
</PropertyGroup>
<!-- Define DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT if requested -->
<PropertyGroup Condition="'$(DisableShaderCompilationSupport)' == 'true'">
<DefineConstants>$(DefineConstants);DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT</DefineConstants>
</PropertyGroup>
<ItemGroup>
@@ -20,6 +14,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
-79
ファイルの表示
@@ -1,79 +0,0 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
#pragma warning disable CS0618
namespace ComputeSharp.Tests.Internals;
[TestClass]
[TestCategory("ShaderBytecode")]
public partial class ShaderBytecodeTests
{
[TestMethod]
public void NonPrecompiledShader_Test()
{
Assert.IsFalse(((IComputeShader)default(NonPrecompiledShader)).TryGetBytecode(32, 1, 1, out ReadOnlySpan<byte> bytecode));
Assert.IsFalse(bytecode.Length > 0);
}
[AutoConstructor]
internal readonly partial struct NonPrecompiledShader : IComputeShader
{
public readonly ReadWriteBuffer<float> buffer;
public readonly float factor;
/// <inheritdoc/>
public void Execute()
{
buffer[ThreadIds.X] *= factor;
}
}
[TestMethod]
public void ComputeShader_Test()
{
Assert.IsTrue(((IComputeShader)default(ComputeShader)).TryGetBytecode(32, 1, 1, out ReadOnlySpan<byte> bytecode));
Assert.IsTrue(bytecode.Length > 0);
Assert.IsFalse(((IComputeShader)default(ComputeShader)).TryGetBytecode(64, 1, 1, out bytecode));
Assert.IsFalse(bytecode.Length > 0);
}
[AutoConstructor]
[EmbeddedBytecode(32, 1, 1)]
internal readonly partial struct ComputeShader : IComputeShader
{
public readonly ReadWriteBuffer<float> buffer;
public readonly float factor;
/// <inheritdoc/>
public void Execute()
{
buffer[ThreadIds.X] *= factor;
}
}
[TestMethod]
public void PixelShader_Test()
{
Assert.IsTrue(((IPixelShader<float4>)default(PixelShader)).TryGetBytecode(8, 8, 1, out ReadOnlySpan<byte> bytecode));
Assert.IsTrue(bytecode.Length > 0);
Assert.IsFalse(((IPixelShader<float4>)default(PixelShader)).TryGetBytecode(32, 1, 1, out bytecode));
Assert.IsFalse(bytecode.Length > 0);
}
[AutoConstructor]
[EmbeddedBytecode(8, 8, 1)]
internal readonly partial struct PixelShader : IPixelShader<float4>
{
public readonly ReadWriteTexture2D<float> buffer;
public readonly float factor;
/// <inheritdoc/>
public float4 Execute()
{
return buffer[ThreadIds.XY] * factor;
}
}
}
+1 -5
ファイルの表示
@@ -1,6 +1,4 @@
#if !DISABLE_RUNTIME_SHADER_COMPILATION_SUPPORT
using System;
using System;
using ComputeSharp.Exceptions;
using ComputeSharp.Shaders.Translation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -47,5 +45,3 @@ public class ShaderCompilerTests
using ComPtr<IDxcBlob> dxcBlob = ShaderCompiler.Instance.CompileShader(faultyShader.AsSpan());
}
}
#endif
+3 -1
ファイルの表示
@@ -27,9 +27,11 @@ public class NativeLibrariesResolverTests
SampleProjectDirectory = Path.Combine(path, "samples", "ComputeSharp.Sample.NuGet");
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 project, to ensure the local NuGet package is available
// Run dotnet pack and on the packaging projects, to ensure the local NuGet packages are available
Process.Start("dotnet", $"pack {packagingProjectPath} -c Release").WaitForExit();
Process.Start("dotnet", $"pack {dynamicPackagingProjectPath} -c Release").WaitForExit();
}
/// <summary>
+48 -48
ファイルの表示
@@ -35,7 +35,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0001");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0001", "CMPS0047");
}
[TestMethod]
@@ -60,7 +60,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0001");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0001", "CMPS0047");
}
[TestMethod]
@@ -88,7 +88,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0002");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0002", "CMPS0047");
}
[TestMethod]
@@ -116,7 +116,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0003");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0003", "CMPS0047");
}
[TestMethod]
@@ -142,7 +142,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0004");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0004", "CMPS0047");
}
[TestMethod]
@@ -159,7 +159,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0005");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0005", "CMPS0047");
}
[TestMethod]
@@ -194,7 +194,7 @@ public class DiagnosticsTests
}}
}}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, diagnosticsId);
VerifyGeneratedDiagnostics<IShaderGenerator>(source, diagnosticsId, "CMPS0047");
}
[TestMethod]
@@ -226,7 +226,7 @@ public class DiagnosticsTests
}}
}}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, diagnosticsId);
VerifyGeneratedDiagnostics<IShaderGenerator>(source, diagnosticsId, "CMPS0047");
}
[TestMethod]
@@ -256,7 +256,7 @@ public class DiagnosticsTests
}}
}}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0006");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0006", "CMPS0047");
}
[TestMethod]
@@ -283,7 +283,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0010", "CMPS0031");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0010", "CMPS0031", "CMPS0047");
}
[TestMethod]
@@ -310,7 +310,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0010", "CMPS0031");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0010", "CMPS0031", "CMPS0047");
}
[TestMethod]
@@ -337,7 +337,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0011", "CMPS0031");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0011", "CMPS0031", "CMPS0047");
}
[TestMethod]
@@ -366,7 +366,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0012");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0012", "CMPS0047");
}
[TestMethod]
@@ -392,7 +392,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0012");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0012", "CMPS0047");
}
[TestMethod]
@@ -419,7 +419,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0012", "CMPS0013");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0012", "CMPS0013", "CMPS0047");
}
[TestMethod]
@@ -448,7 +448,7 @@ public class DiagnosticsTests
}}
}}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0014");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0014", "CMPS0047");
}
[TestMethod]
@@ -480,7 +480,7 @@ public class DiagnosticsTests
}}
}}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0015");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0015", "CMPS0047");
}
[TestMethod]
@@ -512,7 +512,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0016", "CMPS0032");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0016", "CMPS0032", "CMPS0047");
}
[TestMethod]
@@ -544,7 +544,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0017");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0017", "CMPS0047");
}
[TestMethod]
@@ -573,7 +573,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0018");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0018", "CMPS0047");
}
[TestMethod]
@@ -603,7 +603,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0019");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0019", "CMPS0047");
}
[TestMethod]
@@ -633,7 +633,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0020");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0020", "CMPS0047");
}
[TestMethod]
@@ -665,7 +665,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0021");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0021", "CMPS0047");
}
[TestMethod]
@@ -695,7 +695,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0022");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0022", "CMPS0047");
}
[TestMethod]
@@ -727,7 +727,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0023");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0023", "CMPS0047");
}
[TestMethod]
@@ -754,7 +754,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0024");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0024", "CMPS0047");
}
[TestMethod]
@@ -781,7 +781,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0032", "CMPS0025");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0032", "CMPS0025", "CMPS0047");
}
[TestMethod]
@@ -808,7 +808,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0026");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0026", "CMPS0047");
}
[TestMethod]
@@ -840,7 +840,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0027");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0027", "CMPS0047");
}
[TestMethod]
@@ -867,7 +867,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0028");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0028", "CMPS0047");
}
[TestMethod]
@@ -894,7 +894,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0029", "CMPS0031");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0029", "CMPS0031", "CMPS0047");
}
[TestMethod]
@@ -923,7 +923,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0029", "CMPS0031");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0029", "CMPS0031", "CMPS0047");
}
[TestMethod]
@@ -956,7 +956,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0030");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0030", "CMPS0047");
}
[TestMethod]
@@ -983,7 +983,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0031");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0031", "CMPS0047");
}
[TestMethod]
@@ -1010,7 +1010,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0032");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0032", "CMPS0047");
}
[TestMethod]
@@ -1037,7 +1037,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0033");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0033", "CMPS0047");
}
[TestMethod]
@@ -1066,7 +1066,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0034");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0034", "CMPS0047");
}
[TestMethod]
@@ -1095,7 +1095,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0035");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0035", "CMPS0047");
}
[TestMethod]
@@ -1124,7 +1124,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0035");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0035", "CMPS0047");
}
[TestMethod]
@@ -1151,7 +1151,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0036");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0036", "CMPS0047");
}
[TestMethod]
@@ -1194,7 +1194,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0037");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0037", "CMPS0047");
}
[TestMethod]
@@ -1222,7 +1222,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0038");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0038", "CMPS0047");
}
[TestMethod]
@@ -1250,7 +1250,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040", "CMPS0047");
}
[TestMethod]
@@ -1281,7 +1281,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040", "CMPS0047");
}
[TestMethod]
@@ -1309,7 +1309,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040", "CMPS0047");
}
[TestMethod]
@@ -1337,7 +1337,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0040", "CMPS0047");
}
[TestMethod]
@@ -1371,7 +1371,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0041");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0041", "CMPS0047");
}
[TestMethod]
@@ -1396,7 +1396,7 @@ public class DiagnosticsTests
}
}";
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0042");
VerifyGeneratedDiagnostics<IShaderGenerator>(source, "CMPS0042", "CMPS0047");
}
[TestMethod]
+1
ファイルの表示
@@ -16,6 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\ComputeSharp\ComputeSharp.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.Dynamic\ComputeSharp.Dynamic.csproj" />
<ProjectReference Include="..\..\src\ComputeSharp.SourceGenerators\ComputeSharp.SourceGenerators.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"