-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Split StandardMaterialFlags
in two for compatibility with low end GPUs
#11525
base: main
Are you sure you want to change the base?
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
Ive tested this fix on my phone which uses an Adreno 660 which previously couldnt render transparency but with this fix it can. |
could you add comments in the code explaining why it's needed and we can't have everything in a single u32? |
Absolutely, would something like this suffice? // NOTE: These bitflags are separate from StandardMaterialFlags due to a bug on some older GPUs
// that are unable to use the last 16 bits of a u32
bitflags::bitflags! {
/// Bitflags info about the alpha mode of the material a shader is currently rendering.
/// This is accessible in the shader in the [`StandardMaterialUniform`]
#[repr(transparent)]
pub struct StandardMaterialAlphaModeFlags: u32 {
const ALPHA_MODE_OPAQUE = 0;
const ALPHA_MODE_MASK = 1;
const ALPHA_MODE_BLEND = 2;
const ALPHA_MODE_PREMULTIPLIED = 3;
const ALPHA_MODE_ADD = 4;
const ALPHA_MODE_MULTIPLY = 5;
}
} Also this in // 'flags' is a bit field indicating various options.
// u32 is 32 bits so we would have up to 32 options. Some lower-end mobile GPUs only support 16-bits
// so we can only use half of the u32
flags: u32,
alpha_mode_flags: u32, |
@alice-i-cecile Can I ask why this is considered controversial? And is there anything I can do to where its not controversial? |
Twiddling with bitflags for hardware-specific support is always a bit scary. It looks like this is a good approach, but it requires more testing and expert opinion than the average rendering PR as a result. Hmm, actually I think |
Might be worth creating an issue in wgpu (as it could be poly-filled/worked around there) |
I created an issue gfx-rs/wgpu#5318
Is there anything I can do to help out with the testing? |
4525f3e
to
af3795b
Compare
Objective
Fixes #10066
Solution
Added
StandardMaterialAlphaModeFlags
containing the alpha mode bitflags previously inStandardMaterialFlags
. This removes all the bits previously in the last 16-bits of theStandardMaterialFlags
u32
which makes transparency function as intended again.Changelog
Migration Guide