Commit ba04239
authored
Added SSAO support on WebGPU, with R32Float fallback. (#20960)
# Objective
This PR is to add SSAO support on WebGPU.
## Solution
Add r16float detect and fallback to r32float if not supported. FYI the
initial ssao PR [here](#7402).
## Testing
- Did you test these changes? If so, how?
Yes, here is the command to test the ssao example
`RUSTFLAGS="--cfg getrandom_backend=\"wasm_js\"" cargo run --example
ssao --target wasm32-unknown-unknown --features webgpu`
and then http://localhost:1334, make sure it supports
[WebGPU](https://caniuse.com/webgpu)
- Are there any parts that need more testing?
N/A
- How can other people (reviewers) test your changes? Is there anything
specific they need to know?
1. For the R32Float fallback, only the 1st commit is needed. However, I
ran into some strange flickering issue on Chrome (and Chrome canary
too), so I added a "detect_r16float_support" flag and a temp fix in the
2nd and 3rd commit, which are intended to be reverted when merging.
2. with the 1st commit, Safari works fine, but Chrome has the
flickering, and I fixed it by partially reverting a shader change from
#20313, which is very strange. It
is probably caused by some shader optimization issue in Chrome, and I
have no clue why, as the change is just moving the calculation to a
different function.
Here is the flickering on Mac Chrome(140.0.7339.133 (Official Build)
(arm64))
<img width="353" height="327" alt="chrome_ssao"
src="https://github.com/user-attachments/assets/0666673f-508e-4b57-a152-19327ffdb6f3"
/>
- If relevant, what platforms did you test these changes on, and are
there any important ones you can't test?
Tested on native(mac) and WebGPU. To test on native, set
"detect_r16float_support" to false to force R32Float.
I couldn't make the WebGPU ssao example running on Windows 11 Chrome or
Firefox, there is some error in 'taa_pipeline' .
---1 parent 1bd6f42 commit ba04239
File tree
4 files changed
+53
-22
lines changed- crates/bevy_pbr/src/ssao
4 files changed
+53
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | 63 | | |
75 | 64 | | |
76 | 65 | | |
| |||
299 | 288 | | |
300 | 289 | | |
301 | 290 | | |
| 291 | + | |
302 | 292 | | |
303 | 293 | | |
304 | 294 | | |
| |||
307 | 297 | | |
308 | 298 | | |
309 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
310 | 312 | | |
311 | 313 | | |
312 | 314 | | |
| |||
364 | 366 | | |
365 | 367 | | |
366 | 368 | | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
372 | 374 | | |
373 | 375 | | |
374 | 376 | | |
| |||
381 | 383 | | |
382 | 384 | | |
383 | 385 | | |
384 | | - | |
| 386 | + | |
385 | 387 | | |
386 | 388 | | |
387 | 389 | | |
| |||
396 | 398 | | |
397 | 399 | | |
398 | 400 | | |
399 | | - | |
| 401 | + | |
400 | 402 | | |
401 | 403 | | |
402 | 404 | | |
403 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
404 | 411 | | |
405 | 412 | | |
406 | 413 | | |
| |||
409 | 416 | | |
410 | 417 | | |
411 | 418 | | |
| 419 | + | |
412 | 420 | | |
413 | 421 | | |
414 | 422 | | |
| |||
420 | 428 | | |
421 | 429 | | |
422 | 430 | | |
| 431 | + | |
423 | 432 | | |
424 | 433 | | |
425 | 434 | | |
| |||
437 | 446 | | |
438 | 447 | | |
439 | 448 | | |
| 449 | + | |
440 | 450 | | |
441 | 451 | | |
442 | 452 | | |
| |||
465 | 475 | | |
466 | 476 | | |
467 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
468 | 482 | | |
469 | 483 | | |
470 | 484 | | |
| |||
519 | 533 | | |
520 | 534 | | |
521 | 535 | | |
| 536 | + | |
522 | 537 | | |
523 | 538 | | |
524 | 539 | | |
| |||
535 | 550 | | |
536 | 551 | | |
537 | 552 | | |
538 | | - | |
| 553 | + | |
539 | 554 | | |
540 | 555 | | |
541 | 556 | | |
| |||
549 | 564 | | |
550 | 565 | | |
551 | 566 | | |
552 | | - | |
| 567 | + | |
553 | 568 | | |
554 | 569 | | |
555 | 570 | | |
| |||
563 | 578 | | |
564 | 579 | | |
565 | 580 | | |
566 | | - | |
| 581 | + | |
567 | 582 | | |
568 | 583 | | |
569 | 584 | | |
| |||
671 | 686 | | |
672 | 687 | | |
673 | 688 | | |
674 | | - | |
| 689 | + | |
675 | 690 | | |
676 | 691 | | |
677 | 692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
0 commit comments