wgpu/examples/repeated-compute
JustAnotherCodemonkey f738551250
Add Extended Examples (#3885)
* Add the base of the example. May need refining and definitely fact-checking.

* Start change to changelog.

* Complete changelog change for repeated-compute.

* Apply suggestion to fix typos.

Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>

* Add storage-texture example which currently works native but needs to be changed to work for wasm. [no ci]

* repeated-compute now works on the web. [no ci]

* `storage-texture` now works on the web as well as native.

* Format because I forgot to do that (ugh).

* Add `storage-texture` to changelog.

* Add `render-to-texture` example.

* Not all the files got git added. Fixed it.

* Add `render-to-texture` to changelog.

* Make better readme's and add examples to said readme's.

* Oops. Put the example updates in the wrong place.

* Add `uniform-values` example.

* Apply clippy suggestions.

* Improved readme's and documentation.

* Fmt. Turning into the Joker rn.

* Make instructions for examples on the web more clear. \(Fmt and clippy happy\)

* hello-workgroups It doesn't work.

* Add basic comments and readme to hello-workgroups.

* Add hello-synchronization example. Currently doesn't have any tests but those should be added later.

* Forgot to check wasm compatibility for hello-synchronization. Fixed it.

* Add test for hello-synchronization.

* Make my examples downlevel defaults.

* Make uniform-values downlevel defaults. (Forgot to do that last commit.)

* Fix clippy doc complaints.

* Didn't fully fix the docs last commit. Got it here I think.

* Fix redundant bullet point in examples/hello-workgroups/README.md.

* Trim down the introduction section of examples/hello-workgroups/README.md.

* Add technical links section to examples/hello-workgroups/README.md.

* Use idiomatic Rust comments, break up big text wall into paragraphs, and fix some spelling errors.

* Move output image functions into examples/common and give output_image_wasm some upgrades.

* Modify changelog for moving output_image_native and output_image_wasm into wgpu-example.

* Fix output_image_wasm. (Formerly did not handle pre-existing output image targets.)

* Make a multiline comment be made of single lines to be more ideomatic.

* "Fix" more multiline comments. I think this is actually the last of them.

* Make the window a consistant, square size that's convenient for viewing.

* Make the window on uniform-values not endlessly poll, taking up 100% of the main thread in background at idle. Also, change layout a little and make native use nanos by default for logging.

* Make execute in hello-synchronization return a struct of vecs instead of using out parameters.

* Didn't realize the naming of wgpu_example::framework so I moved my common example utility functions into wgpu_example::utils.

* Add add_web_nothing_to_see_msg function to replace all the instances of adding "open the console" messages across the examples.

* Add small documentation to add_web_nothing_to_see_msg and change it to use h1 instead of p.

* Add documentation to output_image_native and output_image_wasm in examples/common.

* Do better logging for output image functions in wgpu-example::utils.

* Remove redundant append_child'ing of the output image element in wgpu-example::utils::output_image_wasm.

* Fix error regarding log message for having written the image in wgpu-example::utils::output_image_native.

* Fmt.

* In examples/README.md, re-arrange the examples in the graph to be in alphabetical order.

* Fix changlog item regarding wgpu-example::utils and the output image functions.

* Move all the added examples into one changelog item that lists all of them.

* Updated table in examples/README.md with new examples. Added new features to the table to accurately represent the examples.\n\nFor the new features, not all old examples may be fully represented.

* Fix inaccurate comment in hello-workgroups/src/shader.wgsl.

* Update examples/README.md to include basic descriptions of the basic examples as well as hints on how examples build off of each other.

* Remove `capture` example. See changelog entry for reasoning.

* Fix typo in hello-workgroups/shader.wgsl

* Change the method of vertex generation in the shader code of render-to-texture to make it more clear.

* Modify/correct message in repeated-compute/main.rs regarding the output staging buffer.

* Update message in uniform-values/main.rs about writing the app state struct to the input WGSL buffer.

* Add notice in repeated-compute/main.rs about why async channels are necessary (portability to WASM).

* Revise comment in uniform-values/main.rs about why we don't cast the struct using POD to be more clear.

* Change uniform-values to use encase for translating AppState to WGSL bytes.

* Cargo & Clippy: My two best friends.

* Add MIT-0 to the list of allowed liscences.

* Fix docs for wasm.

---------

Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
2023-10-08 02:05:51 -04:00
..
src Add Extended Examples (#3885) 2023-10-08 02:05:51 -04:00
Cargo.toml Add Extended Examples (#3885) 2023-10-08 02:05:51 -04:00
README.md Add Extended Examples (#3885) 2023-10-08 02:05:51 -04:00

repeated-compute

Repeatedly performs the Collatz calculation used in hello-compute on sets of random numbers.

Sample

Randomly generated input:

[61917, 53957, 5717, 40520, 41020, 5120, 44281, 19584, 2975, 5310, 4162, 38159, 25343, 16551, 40532, 31464, 64505, 55815, 34793, 24285, 62190, 10530, 49321, 57494, 18473, 18291, 9067, 2665, 53877, 6754, 37616, 51136, 54990, 31159, 38648, 24127, 49640, 12095, 4529, 56275, 18200, 24423, 14065, 17512, 31421, 19612, 63709, 47666, 21805, 13608, 63529, 17809, 6737, 55362, 24647, 30348, 44906, 46325, 503, 52776, 63112, 20785, 63338, 28904, 55772, 56851, 53870, 65503, 30290, 57374, 61244, 39866, 625, 2353, 54901, 25511, 64046, 47882, 22723, 54917, 19563, 24130, 54374, 41964, 3999, 2805, 918, 32932, 6717, 46311, 4818, 28843, 37972, 50981, 31555, 39064, 42814, 37957, 17963, 22678, 3048, 18823, 7293, 63312, 29086, 45580, 5347, 1761, 19090, 41520, 35919, 38705, 51378, 29090, 31100, 55324, 26807, 26017, 24295, 62389, 51934, 27026, 1795, 14965, 51274, 10875, 21396, 22828, 37077, 49922, 46486, 55817, 58928, 64455, 47269, 53484, 6602, 52270, 24417, 6525, 60485, 6389, 10336, 62651, 15721, 8793, 37174, 11962, 768, 21426, 9919, 14295, 55401, 33099, 2221, 9021, 793, 27731, 58923, 28847, 56634, 20447, 33108, 11355, 32437, 15594, 26951, 62607, 28151, 46173, 53140, 48397, 64164, 12279, 54591, 36440, 42712, 3495, 28316, 4674, 35028, 50809, 17289, 3355, 6840, 38134, 29806, 53215, 12076, 55685, 31314, 33548, 51846, 29484, 36845, 12242, 11836, 5449, 11549, 12626, 23699, 52777, 350, 19344, 6380, 63964, 49649, 42487, 26543, 60198, 43868, 38280, 12917, 33574, 44104, 24176, 1348, 47752, 34890, 1471, 34329, 59348, 25115, 148, 62147, 12340, 23654, 26821, 3695, 41075, 15125, 56593, 44273, 34180, 35209, 26294, 48642, 19007, 40617, 46831, 9988, 522, 36478, 64700, 31220, 41376, 43870, 6053, 56665, 56475, 475, 60238, 38170, 53613, 23654, 26273]

Resulting output:

["148", "78", "36", "75", "150", "15", "163", "43", "48", "54", "64", "80", "201", "120", "36", "147", "192", "65", "129", "157", "60", "42", "189", "73", "92", "66", "47", "53", "91", "36", "62", "78", "215", "54", "124", "144", "158", "94", "64", "83", "22", "100", "58", "35", "85", "105", "254", "101", "56", "63", "78", "97", "181", "228", "219", "72", "132", "57", "66", "34", "104", "149", "148", "121", "60", "104", "91", "130", "165", "78", "86", "106", "25", "32", "122", "113", "47", "96", "82", "60", "79", "51", "184", "88", "188", "84", "129", "147", "88", "114", "121", "165", "80", "83", "103", "75", "194", "155", "48", "131", "110", "61", "163", "55", "165", "70", "116", "104", "79", "106", "93", "75", "52", "134", "54", "91", "108", "126", "188", "148", "109", "38", "68", "133", "127", "117", "48", "30", "36", "52", "114", "184", "135", "161", "83", "52", "137", "109", "69", "137", "86", "124", "104", "179", "84", "127", "62", "50", "15", "30", "148", "102", "78", "160", "32", "140", "77", "90", "135", "165", "104", "180", "129", "161", "160", "146", "183", "148", "108", "145", "109", "70", "104", "125", "78", "62", "49", "56", "103", "59", "36", "202", "110", "92", "57", "54", "165", "171", "68", "109", "85", "67", "171", "46", "124", "174", "99", "160", "130", "156", "100", "83", "81", "61", "75", "55", "158", "101", "77", "91", "119", "75", "76", "129", "101", "95", "114", "96", "142", "171", "111", "122", "64", "23", "179", "37", "82", "46", "206", "150", "40", "104", "101", "129", "155", "64", "65", "154", "212", "132", "91", "30", "67", "148", "178", "106", "163", "67", "60", "135", "27", "117", "106", "109", "82", "201"]