Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Adjust raytracer performance #902

Merged
merged 21 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/Uno.Wasm.Sample.RayTracer.Shared/Benchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
{
public Num X, Y, Z;

public static readonly Vec3 Zero = new Vec3();

public Vec3(Num x, Num y, Num z)
{
X = x;
Expand Down Expand Up @@ -115,6 +113,12 @@
}
}

static class Vec3Const
{
// Required for AOT with https://github.com/dotnet/runtime/issues/109170
public static readonly Vec3 Zero = new Vec3();
}

struct Ray
{
public Vec3 Org;
Expand Down Expand Up @@ -226,7 +230,7 @@
}
}

if (obj == null) return Vec3.Zero;
if (obj == null) return Vec3Const.Zero;

var point_of_hit = ray.Org + (ray.Dir * nearest);
var normal = Sphere.Normal(obj, point_of_hit);
Expand All @@ -238,7 +242,7 @@
normal = -normal;
}

Vec3 color = Vec3.Zero;
Vec3 color = Vec3Const.Zero;
var reflection_ratio = obj.Reflection;

foreach(var l in scene.Lights)
Expand Down Expand Up @@ -309,7 +313,7 @@

public static byte[] Render(Scene scene, byte[] pixels)
{
var eye = Vec3.Zero;
var eye = Vec3Const.Zero;
Num h = (Num)Math.Tan(((fov / 360) * (2 * PI)) / 2) * 2;
Num w = h * Width / Height;

Expand Down Expand Up @@ -425,7 +429,7 @@
#if JSIL
public static byte[] Start()
#else
public static async Task Start()

Check warning on line 432 in src/Uno.Wasm.Sample.RayTracer.Shared/Benchmark.cs

View workflow job for this annotation

GitHub Actions / Build and Deploy Job

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
#endif
{
// create objects
Expand Down
Loading