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

Tool for generating indirect function variants #572

Merged
merged 41 commits into from
Aug 25, 2023

Conversation

gkjohnson
Copy link
Owner

@gkjohnson gkjohnson commented Aug 24, 2023

TODO

  • Move all functions that need to be transformed to a common spot
  • Add concurrent rollup watcher to example tester
  • Add final build support
  • Ensure rollup watcher works
  • Fix tests / regressions
  • Test all examples
  • Benchmark
  • Fix extended triangle warning in benchmark, add test

AFTER

  • rearrange files?

let intersection;
/* @if INDIRECT */

intersection = intersectTri( geometry, side, ray, _indirectBuffer ? _indirectBuffer[ i ] : i );

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

The value assigned to intersection here is unused.
let tri;
/* @if INDIRECT */

tri = bvh.resolveTriangleIndex( i );

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

The value assigned to tri here is unused.
@gkjohnson
Copy link
Owner Author

gkjohnson commented Aug 25, 2023

Consistent regressions compared to master:

  • Sphere Shapecast
  • IntersectsBox
  • IntersectsGeometry w/o BVH

BVH Casts

before after delta increase
IntersectsGeometry w/o BVH
*  mean 20.79044 ms 46.31218 ms 25.52174 ms 122.75713 %
*  median 20.75625 ms 46.12933 ms 25.37308 ms 122.24310 %

Tower Case Geometry

before after delta increase
CENTER raycast
*  median 0.00450 ms 0.00479 ms 0.00029 ms 6.48477 %
SAH raycast
*  mean 0.01206 ms 0.01408 ms 0.00202 ms 16.78156 %
*  median 0.00738 ms 0.00879 ms 0.00142 ms 19.21572 %
Full Benchmark

BVH General

before after delta increase
Serialize
   mean 1.09766 ms 0.86283 ms -0.23483 ms -21.39363 %
   median 0.99056 ms 0.83046 ms -0.16010 ms -16.16297 %
Desrialize
   mean 0.12329 ms 0.11396 ms -0.00933 ms -7.56830 %
   median 0.11900 ms 0.11271 ms -0.00629 ms -5.28766 %

BVH Casts

before after delta increase
Compute BVH
   mean 123.28491 ms 122.96133 ms -0.32358 ms -0.26247 %
   median 122.81048 ms 121.36679 ms -1.44369 ms -1.17554 %
Raycast
   mean 0.00424 ms 0.00337 ms -0.00087 ms -20.49605 %
   median 0.00425 ms 0.00317 ms -0.00108 ms -25.48525 %
Raycast First Hit
   mean 0.00197 ms 0.00154 ms -0.00043 ms -21.76053 %
   median 0.00192 ms 0.00146 ms -0.00046 ms -23.93035 %
Sphere Shapecast
   mean 0.00843 ms 0.00693 ms -0.00151 ms -17.84800 %
   median 0.00669 ms 0.00500 ms -0.00169 ms -25.23574 %
IntersectsSphere
   mean 0.00579 ms 0.00511 ms -0.00068 ms -11.69926 %
   median 0.00592 ms 0.00475 ms -0.00117 ms -19.72035 %
IntersectsBox
   mean 0.00881 ms 0.00647 ms -0.00233 ms -26.48201 %
   median 0.00367 ms 0.00369 ms 0.00002 ms 0.55917 %
DistanceToGeometry w/ BVH
   mean 110.93041 ms 108.66213 ms -2.26828 ms -2.04478 %
   median 110.19702 ms 108.60817 ms -1.58886 ms -1.44183 %
DistanceToPoint
   mean 0.11223 ms 0.10609 ms -0.00614 ms -5.47049 %
   median 0.11137 ms 0.10492 ms -0.00646 ms -5.79933 %
IntersectsGeometry w/ BVH
   mean 2.95992 ms 2.95266 ms -0.00726 ms -0.24520 %
   median 2.94475 ms 2.93894 ms -0.00581 ms -0.19738 %
IntersectsGeometry w/o BVH
*  mean 20.79044 ms 46.31218 ms 25.52174 ms 122.75713 %
*  median 20.75625 ms 46.12933 ms 25.37308 ms 122.24310 %

BVH Misc

before after delta increase
Refit
   mean 14.88619 ms 14.93986 ms 0.05367 ms 0.36056 %
   median 14.85917 ms 14.90285 ms 0.04369 ms 0.29401 %
Refit with Hints
   mean 0.50777 ms 0.51101 ms 0.00324 ms 0.63896 %
   median 0.50633 ms 0.50983 ms 0.00350 ms 0.69122 %
Compute Bounds
   mean 0.00067 ms 0.00057 ms -0.00010 ms -14.92793 %
   median 0.00063 ms 0.00054 ms -0.00008 ms -13.31045 %
Compute Bounds w/o
   mean 1.33734 ms 1.37348 ms 0.03614 ms 2.70249 %
   median 1.34344 ms 1.37258 ms 0.02915 ms 2.16953 %

Math Functions

before after delta increase
IntersectTri w/o Target
   mean 0.00058 ms 0.00047 ms -0.00010 ms -17.91838 %
   median 0.00058 ms 0.00046 ms -0.00012 ms -21.26789 %
IntersectTri w/ Target
   mean 0.00074 ms 0.00060 ms -0.00014 ms -18.29019 %
   median 0.00071 ms 0.00058 ms -0.00013 ms -17.75387 %
IntersectTri w/ Update
   mean 0.00121 ms 0.00097 ms -0.00024 ms -19.66125 %
   median 0.00117 ms 0.00096 ms -0.00021 ms -17.91624 %

Tower Case Geometry

before after delta increase
CENTER raycast
   mean 0.00699 ms 0.00716 ms 0.00017 ms 2.46787 %
*  median 0.00450 ms 0.00479 ms 0.00029 ms 6.48477 %
AVERAGE raycast
   mean 0.00244 ms 0.00218 ms -0.00025 ms -10.43865 %
   median 0.00225 ms 0.00204 ms -0.00021 ms -9.24022 %
SAH raycast
*  mean 0.01206 ms 0.01408 ms 0.00202 ms 16.78156 %
*  median 0.00738 ms 0.00879 ms 0.00142 ms 19.21572 %

@gkjohnson
Copy link
Owner Author

before after delta increase
Sphere Shapecast
*  mean 0.00589 ms 0.00647 ms 0.00058 ms 9.88486 %
IntersectsBox
*  median 0.00502 ms 0.00592 ms 0.00090 ms 17.84705 %

Math Functions

before after delta increase
IntersectTri w/o Target
*  median 0.00046 ms 0.00050 ms 0.00004 ms 8.93506 %

Tower Case Geometry

before after delta increase
SAH raycast
*  mean 0.01125 ms 0.01311 ms 0.00187 ms 16.58140 %
Full Benchmark

BVH General

before after delta increase
Serialize
   mean 1.11096 ms 0.85207 ms -0.25889 ms -23.30318 %
   median 0.97131 ms 0.83069 ms -0.14062 ms -14.47782 %
Desrialize
   mean 0.11269 ms 0.11348 ms 0.00079 ms 0.69845 %
   median 0.11108 ms 0.11204 ms 0.00096 ms 0.86238 %

BVH Casts

before after delta increase
Compute BVH
   mean 123.31096 ms 123.64036 ms 0.32940 ms 0.26713 %
   median 122.70527 ms 121.57917 ms -1.12610 ms -0.91773 %
Raycast
   mean 0.00597 ms 0.00338 ms -0.00259 ms -43.33309 %
   median 0.00317 ms 0.00317 ms -0.00000 ms -0.03011 %
Raycast First Hit
   mean 0.00371 ms 0.00152 ms -0.00219 ms -59.00030 %
   median 0.00146 ms 0.00146 ms -0.00000 ms -0.01635 %
Sphere Shapecast
*  mean 0.00589 ms 0.00647 ms 0.00058 ms 9.88486 %
   median 0.00496 ms 0.00500 ms 0.00004 ms 0.82692 %
IntersectsSphere
   mean 0.00513 ms 0.00507 ms -0.00006 ms -1.24017 %
   median 0.00467 ms 0.00469 ms 0.00002 ms 0.43934 %
IntersectsBox
   mean 0.00787 ms 0.00690 ms -0.00097 ms -12.33101 %
*  median 0.00502 ms 0.00592 ms 0.00090 ms 17.84705 %
DistanceToGeometry w/ BVH
   mean 108.88205 ms 108.64503 ms -0.23702 ms -0.21769 %
   median 108.73381 ms 108.47950 ms -0.25431 ms -0.23389 %
DistanceToPoint
   mean 0.11193 ms 0.10618 ms -0.00575 ms -5.13966 %
   median 0.11054 ms 0.10504 ms -0.00550 ms -4.97473 %
IntersectsGeometry w/ BVH
   mean 2.95846 ms 2.95360 ms -0.00486 ms -0.16427 %
   median 2.94252 ms 2.93933 ms -0.00319 ms -0.10832 %
IntersectsGeometry w/o BVH
   mean 20.89428 ms 20.76284 ms -0.13143 ms -0.62905 %
   median 20.75563 ms 20.74142 ms -0.01421 ms -0.06846 %

BVH Misc

before after delta increase
Refit
   mean 14.85720 ms 14.92377 ms 0.06657 ms 0.44806 %
   median 14.83881 ms 14.87235 ms 0.03354 ms 0.22604 %
Refit with Hints
   mean 0.49995 ms 0.50797 ms 0.00802 ms 1.60475 %
   median 0.49925 ms 0.50756 ms 0.00831 ms 1.66501 %
Compute Bounds
   mean 0.00057 ms 0.00057 ms -0.00000 ms -0.76436 %
   median 0.00054 ms 0.00054 ms 0.00000 ms 0.00000 %
Compute Bounds w/o
   mean 1.34160 ms 1.36894 ms 0.02735 ms 2.03835 %
   median 1.34825 ms 1.36754 ms 0.01929 ms 1.43086 %

Math Functions

before after delta increase
IntersectTri w/o Target
   mean 0.00047 ms 0.00048 ms 0.00001 ms 2.03677 %
*  median 0.00046 ms 0.00050 ms 0.00004 ms 8.93506 %
IntersectTri w/ Target
   mean 0.00061 ms 0.00061 ms 0.00000 ms 0.22580 %
   median 0.00058 ms 0.00058 ms 0.00000 ms 0.12265 %
IntersectTri w/ Update
   mean 0.00097 ms 0.00098 ms 0.00001 ms 1.35046 %
   median 0.00096 ms 0.00096 ms 0.00000 ms 0.00000 %

Tower Case Geometry

before after delta increase
CENTER raycast
   mean 0.00686 ms 0.00621 ms -0.00065 ms -9.47367 %
   median 0.00487 ms 0.00483 ms -0.00004 ms -0.86076 %
AVERAGE raycast
   mean 0.00243 ms 0.00217 ms -0.00027 ms -10.95943 %
   median 0.00221 ms 0.00204 ms -0.00017 ms -7.55532 %
SAH raycast
*  mean 0.01125 ms 0.01311 ms 0.00187 ms 16.58140 %
   median 0.00719 ms 0.00650 ms -0.00069 ms -9.57096 %

@gkjohnson gkjohnson merged commit 2795e83 into indirect-redo Aug 25, 2023
2 of 3 checks passed
@gkjohnson gkjohnson deleted the preprocess-indirect branch August 25, 2023 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant