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

Adreno material shader fixes #8589

Closed
wants to merge 2 commits into from

Conversation

gnargfu
Copy link

@gnargfu gnargfu commented May 10, 2023

Objective

Address some issues afflicting the Adreno series of GPUs, specifically on WebGL.
Alpha blending is broken for these GPUs since the standard blending changes were merged.
Also there is an issue related to directional lights and fog.

Fixes #8506
Fixes #8047

Solution

The first issue in relation to alpha blending was a weird one. It could be fixed by moving the flags for the alpha blending from the end of the u32 to just after the last flag from the beginning instead. This seems to be because of some differences in the memory mapping, probably at a lower level. However this fix should work for all other architectures as well.

The second issue is also weird and potentially also related to some as of yet unknown issue with how data is passed between the CPU and the GPU. My best guess is that it is an issue with the Adreno shader compiler that messes up since gpu_directional_lights is an array of 10 by default and it either tries to do some fancy pre-optimization or fumbles when the data is copied over to the gpu here as well. The simplest solution I could think of that works without requiring major changes that would affect all platform is to add a feature that can be passed along if you for some reason need to have your code running specifically on these types of GPUS. Thus I added the limit_directional_light feature that limits the directional lights to 1 but by default it still stays at 10.


Changelog

  • Added limit_directional_light feature that limits the amount of directional lights to one because of issues with the Adreno chipset and fog.

Daniel Norberg added 2 commits May 9, 2023 12:54
On certain Adreno chipsets (such as the 619) the `StandardMaterial`
flags are capped for some reason thus producing issues with how alpha
is being processed. Specifically all meshes were treated by the `bevy_pbr`
shader as being opaque. Moving them to below 16-bits solved the issue
and since there is nothing used above bit-index 9 it should be safe for
all platform/chipsets.
This is useful when targetting certain mobile gpus (Qualcomm/Adreno)
on WebGL.
The shader will currently crash when set to the default 10.
Possibly related to some memory issue in the gpu drivers.
@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@james7132 james7132 added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen labels May 19, 2023
@rparrett
Copy link
Contributor

rparrett commented Jan 9, 2024

Both of the linked issues seem to have been fixed by #8508, so I think this can be closed.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fog crashes on certain mobile devices in WASM WASM WebGL examples crash "wgpu error: Validation Error"
3 participants