From cd7d4c83623c038fdc33d4d5a7984c43551cfd11 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 23 Nov 2021 18:48:32 +0100 Subject: [PATCH] Add shared TerraFX and polyfill references to source generator Also include dxcompiler and dxil as embedded resources --- ComputeSharp.sln | 2 + .../ComputeSharp.SourceGenerators.csproj | 130 ++++++++++-------- .../Core/Interfaces/__Internals/IShader.cs | 0 .../Helpers/HashCode.cs | 47 +++++++ 4 files changed, 119 insertions(+), 60 deletions(-) rename src/ComputeSharp.SourceGenerators/{ => ComputeSharp}/Core/Interfaces/__Internals/IShader.cs (100%) create mode 100644 src/ComputeSharp.SourceGenerators/Helpers/HashCode.cs diff --git a/ComputeSharp.sln b/ComputeSharp.sln index d4c0b7a6..0327debd 100644 --- a/ComputeSharp.sln +++ b/ComputeSharp.sln @@ -84,6 +84,8 @@ Global 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\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 samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{fbd388a5-7855-4408-98ff-e689f509db5a}*SharedItemsImports = 4 diff --git a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj index c6b670e3..6d7afd0c 100644 --- a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj +++ b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj @@ -4,6 +4,7 @@ netstandard2.0 false ComputeSharp.SourceGenerators + $(NoWarn);CS1591;CS0649 @@ -14,63 +15,61 @@ manually linking the source files from ComputeSharp\Core in here. We only need them to extract metadata and to match members based on full name, so the types being in the generator assembly are not an issue.--> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -82,12 +81,23 @@ + - - - + + + + + + + + + + + + + diff --git a/src/ComputeSharp.SourceGenerators/Core/Interfaces/__Internals/IShader.cs b/src/ComputeSharp.SourceGenerators/ComputeSharp/Core/Interfaces/__Internals/IShader.cs similarity index 100% rename from src/ComputeSharp.SourceGenerators/Core/Interfaces/__Internals/IShader.cs rename to src/ComputeSharp.SourceGenerators/ComputeSharp/Core/Interfaces/__Internals/IShader.cs diff --git a/src/ComputeSharp.SourceGenerators/Helpers/HashCode.cs b/src/ComputeSharp.SourceGenerators/Helpers/HashCode.cs new file mode 100644 index 00000000..1861ee67 --- /dev/null +++ b/src/ComputeSharp.SourceGenerators/Helpers/HashCode.cs @@ -0,0 +1,47 @@ +namespace System; + +/// +/// A polyfill type that mirrors some methods from on .NET 6. +/// +internal struct HashCode +{ + /// + /// Combines six values into a hash code. + /// + /// The type of the first value to combine into the hash code. + /// The type of the second value to combine into the hash code. + /// The type of the third value to combine into the hash code. + /// The type of the fourth value to combine into the hash code. + /// The type of the fifth value to combine into the hash code. + /// The type of the sixth value to combine into the hash code. + /// The first value to combine into the hash code. + /// The second value to combine into the hash code. + /// The third value to combine into the hash code. + /// The fourth value to combine into the hash code. + /// The fifth value to combine into the hash code. + /// The sixth value to combine into the hash code. + /// The hash code that represents the six values. + public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) + { + throw new NotSupportedException(); + } + + /// + /// Adds a single value to the hash code. + /// + /// The type of the value to add to the hash code. + /// The value to add to the hash code. + public void Add(T value) + { + throw new NotSupportedException(); + } + + /// + /// Calculates the final hash code after consecutive invocations. + /// + /// The calculated hash code. + public int ToHashCode() + { + throw new NotSupportedException(); + } +} \ No newline at end of file