tag:blogger.com,1999:blog-6042417775578107106.post1665284967802059745..comments2023-08-05T11:30:32.754-04:00Comments on The Hacks of Life: Simultaneous Mipmap Level GenerationChrishttp://www.blogger.com/profile/14648675681957285299noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-6042417775578107106.post-17881350282240821372018-09-15T03:15:52.220-04:002018-09-15T03:15:52.220-04:00I believe that the cache misses caused by followin...I believe that the cache misses caused by following the space-filling curve are totally unnecessary, as well as the complexity of just following the curve.<br /><br />You could just start on the top left (or bottom, if your rows are flipped) of the image and scan across horizontally, tallying up your pixels into corresponding mip buckets just as with the Morton curve, but way more cache-friendly! When you hit the 2nd row of pixels now every 2 pixels you will have completed another 2x2 bucket for the 1st mip level.. Once you hit the 4th row of input image pixels, every 4 pixels of that row you will be completing 4x4 buckets for the 2nd mip level, and two 2x2 buckets on the 2nd row of 1st mip level (with the original image being the 0th level).<br /><br />Writing to buckets in horizontal order might add a little speed boost too.<br /><br />The big different here is that with the Morton curve you're ticking off 4 1st level buckets for every 2nd level bucket (and on and on up the levels) while scanning horizontally you've got a whole row of buckets for every mip level simultaneously until they each get filled up with their last pixel. You'd either sum the integer values and divide at the very end by the miplevel's total added pixels, or you could just sum floating point channel values that are pre-divided (or inverse-multiplied) to save the final division on the completion of the bucket, and just convert to the final channel data format (i.e. 8 bits). There's a good chance this would all be virtually free in the face of the cache misses being practically obliterated.<br /><br />I dunno, maybe I'm missing something. I think it's at least worth investigating.deftwarehttps://www.blogger.com/profile/13361822983119836854noreply@blogger.com