Firstborn/Library/PackageCache/com.unity.burst@1.8.4/Tests/Runtime/Shared/084-Hint.cs
Schaken-Mods 9092858a58 updated to the latest editor
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
2023-05-07 17:43:11 -05:00

66 lines
1.5 KiB
C#

using System;
using static Unity.Burst.CompilerServices.Hint;
namespace Burst.Compiler.IL.Tests
{
internal class Hint
{
[TestCompiler(42)]
public static unsafe double CheckLikely(int val)
{
if (Likely(val < 42))
{
return Math.Pow(Math.Tan(val), 42.42);
}
else
{
return Math.Cos(val);
}
}
[TestCompiler(42)]
public static unsafe double CheckUnlikely(int val)
{
if (Unlikely(val < 42))
{
return Math.Pow(Math.Tan(val), 42.42);
}
else
{
return Math.Cos(val);
}
}
[TestCompiler(42)]
public static unsafe double CheckAssume(int val)
{
Assume(val >= 42);
if (val < 42)
{
return Math.Pow(Math.Tan(val), 42.42);
}
else
{
return Math.Cos(val);
}
}
[TestCompiler(0)]
[TestCompiler(1)]
public static int CheckLikelyMatches(int val)
{
var cond = val == 0;
return cond == Likely(cond) ? 1 : 0;
}
[TestCompiler(0)]
[TestCompiler(1)]
public static int CheckUnlikelyMatches(int val)
{
var cond = val == 0;
return cond == Unlikely(cond) ? 1 : 0;
}
}
}