Bug fixes and optimization to dispatch data buffer

✅ Reduced the cached buffer size from 65KB to 4KB
✅ Fixed out of bounds read when loading dispatch data
このコミットが含まれているのは:
Sergio Pedri committed 2020-12-08 16:02:43 +01:00
1 親 624c1a35d0
コミット 6a5826fdcc
4ファイル変更
+13 -6

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

+2 -3
ファイルの表示
@@ -63,15 +63,14 @@ namespace ComputeSharp.Shaders.Translation.Models
/// <summary>
/// Gets a <see cref="ReadOnlySpan{T}"/> with the padded data representing all the captured variables.
/// </summary>
public ReadOnlySpan<Int4> Variables
public unsafe ReadOnlySpan<Int4> Variables
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
ref byte r0 = ref MemoryMarshal.GetArrayDataReference(this.variablesArray);
ref Int4 r1 = ref Unsafe.As<byte, Int4>(ref r0);
bool mod = (this.variablesByteSize & 15) > 0;
int length = variablesByteSize / 4 + Unsafe.As<bool, byte>(ref mod);
int length = (int)((uint)this.variablesByteSize / (uint)sizeof(Int4));
return MemoryMarshal.CreateReadOnlySpan(ref r1, length);
}