Skip to content

Commit b1c2735

Browse files
authored
chore: Workaround AOT perf
1 parent 9cce982 commit b1c2735

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/Uno.Wasm.Sample.RayTracer.Shared/Benchmark.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ struct Vec3
2626
{
2727
public Num X, Y, Z;
2828

29-
public static readonly Vec3 Zero = new Vec3();
30-
3129
public Vec3(Num x, Num y, Num z)
3230
{
3331
X = x;
@@ -115,6 +113,12 @@ public static Vec3 Normalize(Vec3 v)
115113
}
116114
}
117115

116+
static class Vec3Const
117+
{
118+
// Required for AOT with https://github.com/dotnet/runtime/issues/109170
119+
public static readonly Vec3 Zero = new Vec3();
120+
}
121+
118122
struct Ray
119123
{
120124
public Vec3 Org;
@@ -226,7 +230,7 @@ private static Vec3 trace (Ray ray, Scene scene, int depth)
226230
}
227231
}
228232

229-
if (obj == null) return Vec3.Zero;
233+
if (obj == null) return Vec3Const.Zero;
230234

231235
var point_of_hit = ray.Org + (ray.Dir * nearest);
232236
var normal = Sphere.Normal(obj, point_of_hit);
@@ -238,7 +242,7 @@ private static Vec3 trace (Ray ray, Scene scene, int depth)
238242
normal = -normal;
239243
}
240244

241-
Vec3 color = Vec3.Zero;
245+
Vec3 color = Vec3Const.Zero;
242246
var reflection_ratio = obj.Reflection;
243247

244248
foreach(var l in scene.Lights)
@@ -309,7 +313,7 @@ private static Vec3 trace (Ray ray, Scene scene, int depth)
309313

310314
public static byte[] Render(Scene scene, byte[] pixels)
311315
{
312-
var eye = Vec3.Zero;
316+
var eye = Vec3Const.Zero;
313317
Num h = (Num)Math.Tan(((fov / 360) * (2 * PI)) / 2) * 2;
314318
Num w = h * Width / Height;
315319

src/Uno.Wasm.Sample.RayTracer/Uno.Wasm.Sample.RayTracer.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
1414
<PublishTrimmed>true</PublishTrimmed>
1515
<RunAOTCompilation>true</RunAOTCompilation>
16-
<WasmShellEnableJiterpreter>true</WasmShellEnableJiterpreter>
1716
<!--<RunAOTCompilationAfterBuild>true</RunAOTCompilationAfterBuild>-->
1817
<WasmAotProfilePath>$(MSBuildThisFileDirectory)aot.profile</WasmAotProfilePath>
1918
<!-- <WasmShellGenerateAOTProfile>true</WasmShellGenerateAOTProfile> -->

0 commit comments

Comments
 (0)