-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I was investigating why this sample didn't work on compat mode in Chrome. I found 1 issue in the code which is the shader that makes the probability map only worked if the source image is was a multiple of 64 pixels wide. This was because it was not conditionally skipping out of bounds pixels and so processing those pixels would end up overwriting other results. This issue does not come up in the sample but if you change the image to some image that is not a multiple of 64 pixels across the issue comes up. In debugging why GL was failing, one my paths was to make a 16x16 pixel `F` using the canvas 2D api and passing that in so that I could print all of the data. With that I ran into this issue. So, I added the skipping. Thank's to Peter McNeeley for finding that issue. While pursing the code I find somethings I though maybe should be refactored? * Calculating the number of mip level was done in a loop. Changed it to just math. * Moving some calculations to use properties on the texture. I can revert these changes. They were useful when I switched the source image to a canvas since then the code didn't depend on variables that were no longer available. * Getting rid of `struct Buffer` I can revert these changes. I get the impression that this was a limitation of an earlier version of WGSL? It seems more confusing to me personally to have a struct with a single array in it than to just have the array. * Simpler math I can revert this but, changed `sum = dot(vec4f(a, b, c, d), vec4f(1.0))` to `sum = a + b + c + d`. Note that, even with the change for the first pass, the code only works for square power-of-2 images. Both the probability generation and the usage of that data require each mip level to be exactly 1/2 the size of the previous level. So, added some asserts so people copying this won't stumble into issues.
- Loading branch information
Showing
2 changed files
with
58 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters