30% overhead reduction for dispatching

Also removed MS.Experimental.Collections dependency
このコミットが含まれているのは:
Sergio Pedri committed 2020-09-02 13:44:46 +02:00
1 親 f7a9c0d341
コミット 4433e8f317
4ファイル変更
+8 -24

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

-1
ファイルの表示
@@ -9,7 +9,6 @@
<ItemGroup>
<PackageReference Include="ICSharpCode.Decompiler" Version="5.0.2.5153" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.7.0" />
<PackageReference Include="Microsoft.Experimental.Collections" Version="1.0.6-e190117-3" />
<PackageReference Include="Stubble.Core" Version="1.9.3" />
<PackageReference Include="Vortice.Dxc" Version="1.8.3" />
</ItemGroup>
+3 -3
ファイルの表示
@@ -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
/// <summary>
/// The mapping used to cache and reuse compiled shaders
/// </summary>
private static readonly DictionarySlim<ShaderKey, CachedShader<T>> ShadersCache = new DictionarySlim<ShaderKey, CachedShader<T>>();
private static readonly Dictionary<ShaderKey, CachedShader<T>> ShadersCache = new Dictionary<ShaderKey, CachedShader<T>>();
/// <summary>
/// Compiles and runs the input shader on a target <see cref="GraphicsDevice"/> 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<T>(shaderLoader, shaderBytecode);
ShadersCache.Add(key, shaderData = new CachedShader<T>(shaderLoader, shaderBytecode));
}
}
+5 -19
ファイルの表示
@@ -1,37 +1,31 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace ComputeSharp.Shaders.Translation.Models
{
/// <summary>
/// A <see langword="struct"/> representing a key for a given shader
/// </summary>
[StructLayout(LayoutKind.Explicit)]
internal readonly struct ShaderKey : IEquatable<ShaderKey>
{
/// <summary>
/// The hashcode of the current shader type
/// </summary>
[FieldOffset(0)]
private readonly int Id;
/// <summary>
/// The number of iterations to run on the X axis
/// </summary>
[FieldOffset(4)]
private readonly int ThreadsX;
/// <summary>
/// The number of iterations to run on the Y axis
/// </summary>
[FieldOffset(8)]
private readonly int ThreadsY;
/// <summary>
/// The number of iterations to run on the Z axis
/// </summary>
[FieldOffset(12)]
private readonly int ThreadsZ;
/// <summary>
@@ -55,10 +49,10 @@ namespace ComputeSharp.Shaders.Translation.Models
public bool Equals(ShaderKey other)
{
return
Unsafe.As<int, ulong>(ref Unsafe.AsRef(Id))
== Unsafe.As<int, ulong>(ref Unsafe.AsRef(other.Id)) &&
Unsafe.As<int, ulong>(ref Unsafe.AsRef(ThreadsY))
== Unsafe.As<int, ulong>(ref Unsafe.AsRef(other.ThreadsY));
Id == other.Id &&
ThreadsX == other.ThreadsX &&
ThreadsY == other.ThreadsY &&
ThreadsZ == other.ThreadsZ;
}
/// <inheritdoc/>
@@ -71,15 +65,7 @@ namespace ComputeSharp.Shaders.Translation.Models
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode()
{
ulong ul0 = Unsafe.As<int, ulong>(ref Unsafe.AsRef(Id));
int hash = unchecked((int)ul0) ^ (int)(ul0 >> 32);
ulong ul1 = Unsafe.As<int, ulong>(ref Unsafe.AsRef(ThreadsY));
hash = (hash << 5) + hash + unchecked((int)ul1) ^ ((int)(ul1 >> 32));
return hash;
return HashCode.Combine(Id, ThreadsX, ThreadsY, ThreadsZ);
}
}
}
-1
ファイルの表示
@@ -21,7 +21,6 @@
<dependency id="Vortice.Direct3D12" version="1.8.3" />
<dependency id="ICSharpCode.Decompiler" version="5.0.2.5153" />
<dependency id="Microsoft.CodeAnalysis.CSharp" version="3.7.0" />
<dependency id="Microsoft.Experimental.Collections" version="1.0.6-e190117-3" />
<dependency id="Stubble.Core" version="1.9.3" />
<dependency id="Vortice.Dxc" version="1.8.3" />
</dependencies>