Skip to content

Commit

Permalink
CS9195 remediation.
Browse files Browse the repository at this point in the history
  • Loading branch information
RossNordby committed Nov 14, 2023
1 parent 13b9ff3 commit 72c25a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion BepuPhysics/Trees/Tree_SelfQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public static Vector128<int> GetLeftPackMask(Vector128<int> mask, out int count)
0b1110_0100, 0b1110_0100, 0b1110_0101, 0b1110_0100, 0b1110_0110, 0b1110_1000, 0b1110_1001, 0b1110_0100,
//1000 1001 1010 1011 1100 1101 1110 1111
0b1110_0111, 0b1110_1100, 0b1110_1101, 0b1111_0100, 0b1110_1110, 0b1111_1000, 0b1111_1001, 0b1110_0100 };
var encodedLeftPackMask = Unsafe.Add(ref Unsafe.AsRef(lookupTable[0]), bitmask);
var encodedLeftPackMask = Unsafe.Add(ref Unsafe.AsRef(in lookupTable[0]), bitmask);

count = BitOperations.PopCount(bitmask);
//Broadcast, variable shift.
Expand Down
36 changes: 18 additions & 18 deletions BepuUtilities/BoundingBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public unsafe static bool IntersectsUnsafe<TA, TB>(in TA boundingBoxA, in TB bou
if (Vector128.IsHardwareAccelerated)
{
//THIS IS A POTENTIAL GC HOLE IF CHILDREN ARE PASSED FROM UNPINNED MANAGED MEMORY
ref var a = ref Unsafe.As<TA, float>(ref Unsafe.AsRef(boundingBoxA));
ref var b = ref Unsafe.As<TB, float>(ref Unsafe.AsRef(boundingBoxB));
ref var a = ref Unsafe.As<TA, float>(ref Unsafe.AsRef(in boundingBoxA));
ref var b = ref Unsafe.As<TB, float>(ref Unsafe.AsRef(in boundingBoxB));
var aMin = Vector128.LoadUnsafe(ref a);
var aMax = Vector128.LoadUnsafe(ref Unsafe.Add(ref a, 4));
var bMin = Vector128.LoadUnsafe(ref b);
Expand All @@ -106,8 +106,8 @@ public unsafe static bool IntersectsUnsafe<TA, TB>(in TA boundingBoxA, in TB bou
}
else
{
var a = (float*)Unsafe.AsPointer(ref Unsafe.AsRef(boundingBoxA));
var b = (float*)Unsafe.AsPointer(ref Unsafe.AsRef(boundingBoxB));
var a = (float*)Unsafe.AsPointer(ref Unsafe.AsRef(in boundingBoxA));
var b = (float*)Unsafe.AsPointer(ref Unsafe.AsRef(in boundingBoxB));
return a[4] >= b[0] & a[5] >= b[1] & a[6] >= b[2] &
b[4] >= a[0] & b[5] >= a[1] & b[6] >= a[2];
}
Expand Down Expand Up @@ -207,11 +207,11 @@ public static void CreateMergedUnsafeWithPreservation<TA, TB>(in TA boundingBoxA
ref var resultMin = ref Unsafe.As<TA, Vector128<float>>(ref merged);
ref var resultMax = ref Unsafe.Add(ref Unsafe.As<TA, Vector128<float>>(ref merged), 1);
var min = Vector128.Min(
Unsafe.As<TA, Vector128<float>>(ref Unsafe.AsRef(boundingBoxA)),
Unsafe.As<TB, Vector128<float>>(ref Unsafe.AsRef(boundingBoxB)));
Unsafe.As<TA, Vector128<float>>(ref Unsafe.AsRef(in boundingBoxA)),
Unsafe.As<TB, Vector128<float>>(ref Unsafe.AsRef(in boundingBoxB)));
var max = Vector128.Max(
Unsafe.Add(ref Unsafe.As<TA, Vector128<float>>(ref Unsafe.AsRef(boundingBoxA)), 1),
Unsafe.Add(ref Unsafe.As<TB, Vector128<float>>(ref Unsafe.AsRef(boundingBoxB)), 1));
Unsafe.Add(ref Unsafe.As<TA, Vector128<float>>(ref Unsafe.AsRef(in boundingBoxA)), 1),
Unsafe.Add(ref Unsafe.As<TB, Vector128<float>>(ref Unsafe.AsRef(in boundingBoxB)), 1));
if (Sse41.IsSupported)
{
resultMin = Sse41.Blend(min, resultMin, 0b1000);
Expand All @@ -226,10 +226,10 @@ public static void CreateMergedUnsafeWithPreservation<TA, TB>(in TA boundingBoxA
}
else
{
ref var a = ref Unsafe.As<TA, BoundingBox>(ref Unsafe.AsRef(boundingBoxA));
ref var b = ref Unsafe.As<TB, BoundingBox>(ref Unsafe.AsRef(boundingBoxB));
ref var a = ref Unsafe.As<TA, BoundingBox>(ref Unsafe.AsRef(in boundingBoxA));
ref var b = ref Unsafe.As<TB, BoundingBox>(ref Unsafe.AsRef(in boundingBoxB));
Unsafe.SkipInit(out merged);
ref var result = ref Unsafe.As<TA, BoundingBox>(ref Unsafe.AsRef(merged));
ref var result = ref Unsafe.As<TA, BoundingBox>(ref Unsafe.AsRef(in merged));
result.Min = Vector3.Min(a.Min, b.Min);
result.Max = Vector3.Max(a.Max, b.Max);
}
Expand All @@ -253,18 +253,18 @@ public static void CreateMergedUnsafe<TA, TB>(in TA boundingBoxA, in TB bounding
ref var resultMin = ref Unsafe.As<TA, Vector128<float>>(ref merged);
ref var resultMax = ref Unsafe.Add(ref Unsafe.As<TA, Vector128<float>>(ref merged), 1);
resultMin = Vector128.Min(
Unsafe.As<TA, Vector128<float>>(ref Unsafe.AsRef(boundingBoxA)),
Unsafe.As<TB, Vector128<float>>(ref Unsafe.AsRef(boundingBoxB)));
Unsafe.As<TA, Vector128<float>>(ref Unsafe.AsRef(in boundingBoxA)),
Unsafe.As<TB, Vector128<float>>(ref Unsafe.AsRef(in boundingBoxB)));
resultMax = Vector128.Max(
Unsafe.Add(ref Unsafe.As<TA, Vector128<float>>(ref Unsafe.AsRef(boundingBoxA)), 1),
Unsafe.Add(ref Unsafe.As<TB, Vector128<float>>(ref Unsafe.AsRef(boundingBoxB)), 1));
Unsafe.Add(ref Unsafe.As<TA, Vector128<float>>(ref Unsafe.AsRef(in boundingBoxA)), 1),
Unsafe.Add(ref Unsafe.As<TB, Vector128<float>>(ref Unsafe.AsRef(in boundingBoxB)), 1));
}
else
{
ref var a = ref Unsafe.As<TA, BoundingBox>(ref Unsafe.AsRef(boundingBoxA));
ref var b = ref Unsafe.As<TB, BoundingBox>(ref Unsafe.AsRef(boundingBoxB));
ref var a = ref Unsafe.As<TA, BoundingBox>(ref Unsafe.AsRef(in boundingBoxA));
ref var b = ref Unsafe.As<TB, BoundingBox>(ref Unsafe.AsRef(in boundingBoxB));
Unsafe.SkipInit(out merged);
ref var result = ref Unsafe.As<TA, BoundingBox>(ref Unsafe.AsRef(merged));
ref var result = ref Unsafe.As<TA, BoundingBox>(ref Unsafe.AsRef(in merged));
result.Min = Vector3.Min(a.Min, b.Min);
result.Max = Vector3.Max(a.Max, b.Max);
}
Expand Down

0 comments on commit 72c25a8

Please sign in to comment.