cinera_handmade.network/cmuratori/hero/code/code595.hmml

102 lines
8.4 KiB
Plaintext
Raw Normal View History

[video output=day595 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Sketching Out A K-d Tree Loop" vod_platform=youtube id=3vWqM96zT-w annotator=Miblo]
2020-04-21 17:56:24 +00:00
[0:00][Welcome to the stream with a plug of the Meow the Infinite printed comic Kickstarter[ref
site=Kickstarter
page="Meow the Infinite: Book One"
url=https://www.kickstarter.com/projects/annarettberg/meow-the-infinite-book-one]][:speech]
[0:57][Show RayCast() with the determination to use our ray cast hits as a k-d tree][:lighting :optimisation :research]
[1:37][Demo hhlightprof (6.538543 total seconds elapsed)][:lighting :optimisation :run]
[2:50][Print out the number of partitions and leaves tested over repeated runs][:lighting :optimisation]
[6:14][hhlightprof tested 229860 partitions, and 524241 leaves][:lighting :optimisation :profiling :run]
[6:27][Always print out the number of partition and leaves tested, including the single-run case][:lighting :optimisation :profiling]
[6:44][hhlightprof tested 2338596 partitions, and 524285 leaves][:lighting :optimisation :profiling :run]
[6:53][Revert hhlightprof to print the number of partitions and leaves tested in the multiple-run case][:lighting :optimisation :profiling]
[7:03][Print partitions per leaf][:lighting :optimisation :profiling]
[8:32][hhlightprof tested 2339860 partitions and 524241 leaves, at 4.46 partitions per leaf][:lighting :optimisation :profiling :run]
[8:55][Print total partitions plus leaves][:lighting :optimisation :profiling]
[9:35][hhlightprof tested 2864101 total boxes, 2339860 partitions and 524241 leaves, at 4.46 partitions per leaf][:lighting :optimisation :profiling :run]
[11:25][Determine to make a special-purpose design for the k-d tree][:"data structure" :lighting :optimisation :speech]
[13:19][Check the day[ref
site="Handmade Hero"
page="Episode Guide"
url=https://handmadehero.org/watch#EpisodeGuide][ref
site=YouTube
page="Molly Rocket"
url=https://www.youtube.com/c/MollyRocket]][:research]
[14:19][k-d Tree][:blackboard :"data structure"]
[19:37][Embark on k-d tree-style categorisation in RayCast()][:"data structure" :lighting :optimisation]
[22:35][Doing a dot-product using a known +/ value[ref
site=Intel
page="Intel Intrinsics Guide"
url=https://software.intel.com/sites/landingpage/IntrinsicsGuide/]][:lighting :optimisation :research :simd]
[24:56][Initialise our desired data for k-d tree-style categorisation in RayCast()][:"data structure" :lighting :optimisation]
[32:23][Our menu of operations: 1) Push both boxes; 2) Push one box; 3) Push no boxes][:"data structure" :lighting :optimisation :research]
[33:06][Pushing no boxes][:blackboard :"data structure" :lighting :optimisation]
[34:29][Set up RayCast() to push onto our BoxStack the boxes on the close side and, optionally, the far side][:"data structure" :lighting :optimisation]
[37:38][Consider the resource-usage implications of four rays sharing the same origin][:"data structure" :lighting :optimisation :research :simd]
[46:38][Determine to use :SIMD lanes suboptimally for now, then read the literature on k-d trees to inform any improvements][:"data structure" :lighting :optimisation :research]
[47:31][Make RayCast() push the boxes onto our BoxStack][:"data structure" :lighting :optimisation]
[57:52][Consider how to classify the EndSide in terms of signedness][:"data structure" :lighting :optimisation :research]
[1:03:04][Work through the EndSide classification, XOR'ing the sides into a mask][:"data structure" :lighting :optimisation]
[1:06:46][Consider restructuring the box categorisation loop][:"data structure" :lighting :optimisation :research]
[1:07:30][Restructure the box categorisation loop such that a box pulled off the stack is always known to be on the far side][:"data structure" :lighting :optimisation]
[1:12:22][Set up to take a timing]
[1:13:03][hhlightprof total seconds elapsed: 6.362055][:lighting :optimisation :run]
[1:13:35][Restructure the ray hit testing loop within the categorisation loop, to avoid unnecessary box pushes][:lighting :optimisation]
[1:18:13][hhlightprof total seconds elapsed: 6.110083][:lighting :optimisation :run]
[1:18:41][Remove stale code from RayCast()][:lighting :optimisation]
[1:19:41][Continue to work through the box categorisation routine][:"data structure" :lighting :optimisation]
[1:21:53][hhlightprof total seconds elapsed: 6.173270][:lighting :optimisation :run]
[1:22:11][Print out the Expected ms][:lighting :optimisation :profiling]
[1:23:00][hhlightprof expected ms: 50.74][:lighting :optimisation :run]
[1:23:44][Print out the Expected ms / thread][:lighting :optimisation :profiling]
[1:24:16][hhlightprof expected ms / thread: 8.49][:lighting :optimisation :run]
[1:24:51][Undefine HANDMADE_INTERNAL and HANDMADE_SLOW]
[1:25:07][hhlightprof expected ms / thread: 8.51][:lighting :optimisation :run]
[1:25:15][:Run the game][:lighting :optimisation :run]
[1:26:06][:Run the game in Nsight: 21 ms / frame][:lighting :optimisation :profiling]
[1:27:53][Check our frame profile in Nsight][:lighting :optimisation :profiling :run]
[1:29:08][Decrease our resolution from 1920×1080 to 480×270][:rendering]
[1:29:43][:Run the game][:lighting :optimisation :run]
[1:30:15][:Run the game in Nsight: 21 ms / frame][:lighting :optimisation :profiling]
[1:31:06][Increase our resolution from 480×270 to 1920×1080][:rendering]
[1:31:13][Disable the :lighting in EndLightingComputation()]
[1:31:49][:Run the game][:lighting :optimisation :run]
[1:32:09][:Run the game in Nsight: 16.67 ms / frame][:lighting :optimisation :profiling]
[1:32:36][Re-enable the :lighting in EndLightingComputation()]
[1:32:42][Make ComputeLightPropagationWork() compute the :lighting for only every other tile]
[1:34:16][:Run the game in Nsight: 16.67 ms / frame][:lighting :optimisation :profiling]
[1:35:24][Revert ComputeLightPropagationWork() to compute the :lighting for every tile]
[1:35:32][Continue work on structuring our categorisation loop for better k-d processing][:"data structure" :lighting :optimisation]
[1:44:24][Our menu of split cases][:blackboard :"data structure" :lighting :optimisation]
[1:47:01][Complete our categorisation and ray hit testing loops for better k-d processing][:"data structure" :lighting :optimisation]
[2:03:40][Reflect on our k-d tree-based RayCast()][:"data structure" :lighting :optimisation :speech]
[2:04:26][Q&A][:speech]
[2:05:02][@insobot][Q: Groovy?]
[2:05:35][@nulligor][Q: Is this PHP?][:language]
[2:05:56][@ablindorphan][Q: Is there a good way to get intuitions about bit masks etc, or is it just practice?[ref
site=Intel
page="Intel Intrinsics Guide"
url=https://software.intel.com/sites/landingpage/IntrinsicsGuide/]][:language]
[2:07:12][Fix our usage of _mm_movemask_ps() in the StartSideBit and EndSideBit initialisers][:simd]
[2:07:30][Describe _mm_movemask_ps[ref
site=Intel
page="Intel Intrinsics Guide"
url=https://software.intel.com/sites/landingpage/IntrinsicsGuide/]][:research :simd]
[2:08:54][@read_my_code][Q: Do you write shader code often for work?]
[2:09:27][@alexkelbo][Q: Do you sometimes feel the urge to make [~hero Handmade Hero] truly 3D?]
[2:10:49][@read_my_code][Your asset pipeline becomes Unreal Engine 4]
[2:12:15][@ymm0][Q: I'm bit behind on the VoDs. Do you ever trace secondary rays that bounce off in random directions that might lead to incoherent ray packets? (You mentioned the ray origins are always the same)][:lighting]
[2:13:36][@uplinkcoder][Q: Can't C++11 use something like 0b1111[ref
site="cppreference"
page="integer literal"
url=http://en.cppreference.com/w/cpp/language/integer_literal]][:language]
[2:15:49][@sneiderlein][Q: In an IMGUI situation, how do you create a unique ID for a :UI control? What I don't get is, if you draw everything immediately, if some condition changes, won't the ID also change?]
[2:16:39][@mjt_au][Q: Has [~hero Handmade Hero] gone as you planned, or did you not have any expectations or scope when you set off on this journey?]
[2:17:02][@nulligor][Q: How many % is [~hero Handmade Hero] done?]
[2:17:45][@i_simian][Q: Would you consider moving [~hero Handmade Hero] to JAI when it releases, or perhaps have another project to help showcase the :language? I assume it'd be something that would at least interest you]
[2:18:24][Wrap it up with a plug of the Meow the Infinite printed comic Kickstarter[ref
site=Kickstarter
page="Meow the Infinite: Book One"
url=https://www.kickstarter.com/projects/annarettberg/meow-the-infinite-book-one]][:speech]
[/video]