Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix motion blur on wasm #13099

Merged
merged 7 commits into from
May 12, 2024
Merged

Fix motion blur on wasm #13099

merged 7 commits into from
May 12, 2024

Conversation

rparrett
Copy link
Contributor

@rparrett rparrett commented Apr 25, 2024

Objective

Fixes #13097 and other issues preventing the motion blur example from working on wasm

Solution

  • Use a vec2 for padding
  • Fix error initializing the MotionBlur struct on wasm+webgl2
  • Disable MSAA on wasm+webgl2
  • Fix GlobalsUniform padding getting added on the shader side for webgpu builds

Notes

The motion blur example now runs, but with artifacts. In addition to the obvious black artifacts, the motion blur or dithering seem to just look worse in a way I can't really describe. That may be expected.

AdapterInfo { name: "ANGLE (Apple, ANGLE Metal Renderer: Apple M1 Max, Unspecified Version)", vendor: 4203, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }
Screenshot 2024-04-25 at 6 51 21 AM

@NthTensor NthTensor added A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior labels Apr 25, 2024
@alice-i-cecile alice-i-cecile added this to the 0.14 milestone Apr 25, 2024
@rparrett
Copy link
Contributor Author

rparrett commented Apr 29, 2024

It seems that there are other issues when building with webgpu that need to be addressed:

The shader uses more bytes of the buffer (16) than the layout's minBindingSize (12).
 - While validating that the entry-point's declaration for @group(0) @binding(5) matches [BindGroupLayout "motion_blur_layout"]
 - While validating the entry-point's compatibility for group 0 with [BindGroupLayout "motion_blur_layout"]
 - While validating fragment stage ([ShaderModule (unlabeled)], entryPoint: fragment).
 - While validating fragment state.
 - While calling [Device].CreateRenderPipeline([RenderPipelineDescriptor "motion_blur_pipeline"]).

edit: binding 5 is Globals, so this seems unrelated to padding in MotionBlur.

@rparrett
Copy link
Contributor Author

Tested motion_blur with webgpu, webgl2, and on native (m1 mac). Now working everywhere, but the black artifacts are present in all web builds.

I had to modify the cfg gating for SIXTEEN_BYTE_ALIGNMENT to account for the webgl and webgpu features no longer being mutually exclusive. I'm not totally confident this was the correct thing to do or if that might have other side effects.

Copy link
Contributor

@kristoff3r kristoff3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just standard annoying webgl2 padding. I tested on Linux and wasm webgl2 and both works.

@aevyrie
Copy link
Member

aevyrie commented May 2, 2024

Bummer, this was working at one point, but I forgot to re-test closer to final merge. Thanks!

@rparrett rparrett added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label May 7, 2024
@james7132 james7132 added this pull request to the merge queue May 12, 2024
Merged via the queue into bevyengine:main with commit 2fd432c May 12, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Likely overpadded motion blur struct
9 participants