diff --git a/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj b/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj
index cdcd8634..89e2b2b4 100644
--- a/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj
+++ b/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj
@@ -9,7 +9,6 @@
-
diff --git a/src/ComputeSharp.Shaders/ShaderRunner{T}.cs b/src/ComputeSharp.Shaders/ShaderRunner{T}.cs
index 488256e3..9cc1344d 100644
--- a/src/ComputeSharp.Shaders/ShaderRunner{T}.cs
+++ b/src/ComputeSharp.Shaders/ShaderRunner{T}.cs
@@ -1,11 +1,11 @@
using System;
+using System.Collections.Generic;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Shaders.Renderer;
using ComputeSharp.Shaders.Renderer.Models;
using ComputeSharp.Shaders.Translation;
using ComputeSharp.Shaders.Translation.Models;
-using Microsoft.Collections.Extensions;
using Vortice.Direct3D12;
using CommandList = ComputeSharp.Graphics.Commands.CommandList;
using PipelineState = ComputeSharp.Graphics.Commands.PipelineState;
@@ -41,7 +41,7 @@ namespace ComputeSharp.Shaders
///
/// The mapping used to cache and reuse compiled shaders
///
- private static readonly DictionarySlim> ShadersCache = new DictionarySlim>();
+ private static readonly Dictionary> ShadersCache = new Dictionary>();
///
/// Compiles and runs the input shader on a target instance, with the specified parameters
@@ -89,7 +89,7 @@ namespace ComputeSharp.Shaders
ShaderBytecode shaderBytecode = ShaderCompiler.CompileShader(shaderSource);
// Cache for later use
- ShadersCache.GetOrAddValueRef(key) = shaderData = new CachedShader(shaderLoader, shaderBytecode);
+ ShadersCache.Add(key, shaderData = new CachedShader(shaderLoader, shaderBytecode));
}
}
diff --git a/src/ComputeSharp.Shaders/Translation/Models/ShaderKey.cs b/src/ComputeSharp.Shaders/Translation/Models/ShaderKey.cs
index 89c3cd1d..1acaca5b 100644
--- a/src/ComputeSharp.Shaders/Translation/Models/ShaderKey.cs
+++ b/src/ComputeSharp.Shaders/Translation/Models/ShaderKey.cs
@@ -1,37 +1,31 @@
using System;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
namespace ComputeSharp.Shaders.Translation.Models
{
///
/// A representing a key for a given shader
///
- [StructLayout(LayoutKind.Explicit)]
internal readonly struct ShaderKey : IEquatable
{
///
/// The hashcode of the current shader type
///
- [FieldOffset(0)]
private readonly int Id;
///
/// The number of iterations to run on the X axis
///
- [FieldOffset(4)]
private readonly int ThreadsX;
///
/// The number of iterations to run on the Y axis
///
- [FieldOffset(8)]
private readonly int ThreadsY;
///
/// The number of iterations to run on the Z axis
///
- [FieldOffset(12)]
private readonly int ThreadsZ;
///
@@ -55,10 +49,10 @@ namespace ComputeSharp.Shaders.Translation.Models
public bool Equals(ShaderKey other)
{
return
- Unsafe.As(ref Unsafe.AsRef(Id))
- == Unsafe.As(ref Unsafe.AsRef(other.Id)) &&
- Unsafe.As(ref Unsafe.AsRef(ThreadsY))
- == Unsafe.As(ref Unsafe.AsRef(other.ThreadsY));
+ Id == other.Id &&
+ ThreadsX == other.ThreadsX &&
+ ThreadsY == other.ThreadsY &&
+ ThreadsZ == other.ThreadsZ;
}
///
@@ -71,15 +65,7 @@ namespace ComputeSharp.Shaders.Translation.Models
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode()
{
- ulong ul0 = Unsafe.As(ref Unsafe.AsRef(Id));
-
- int hash = unchecked((int)ul0) ^ (int)(ul0 >> 32);
-
- ulong ul1 = Unsafe.As(ref Unsafe.AsRef(ThreadsY));
-
- hash = (hash << 5) + hash + unchecked((int)ul1) ^ ((int)(ul1 >> 32));
-
- return hash;
+ return HashCode.Combine(Id, ThreadsX, ThreadsY, ThreadsZ);
}
}
}
diff --git a/src/ComputeSharp/ComputeSharp.nuspec b/src/ComputeSharp/ComputeSharp.nuspec
index f521f29b..d2c4be2c 100644
--- a/src/ComputeSharp/ComputeSharp.nuspec
+++ b/src/ComputeSharp/ComputeSharp.nuspec
@@ -21,7 +21,6 @@
-